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.
1
Expert's answer
2013-04-09T10:34:52-0400
#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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS