60 658
Assignments Done
97,7%
Successfully Done
In April 2018

Answer to Question #27821 in C++ for Faisal

Question #27821
Write a program that output the following:
A
* *
B C D
* * * *
E F G H I
* * * * * *
Hint: Use nested Loops.
Expert's answer
#include <stdio.h>
#include <cstdlib>
#include <iostream>

using namespace std;


int main ()
{
int n = 6;
char letter = 'A';
for (int i = 0; i < n; i++) {
& for (int j = 0; j <= i; j++) {
printf("%s%c", j ? " " : "", i % 2 == 0 ? letter++ : '*');
& }
& printf("\n");
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions