Answer to Question #28609 in C++ for bala

Question #28609
Use for loops to construct a program that displays a pyramid of Xs on the screen. The
pyramid should look like this
X
XXX
XXXXX
XXXXXXX
XXXXXXXXX
1
Expert's answer
2013-04-17T09:29:13-0400
#include<conio.h>
#include<iostream>
usingnamespace std;

//mainfunction
voidmain(){

//show result
for(int i = 1; i < 10; i+=2) {
cout<< "
";//shownew line
for(int j = 1; j <=i; j++)
cout << "*";// show asterisk
}
getch();//delay

}

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