76 373
Assignments Done
Successfully Done
In May 2019

Answer to Question #28603 in C++ for bala

Question #28603
Use for loops to construct a program that displays a pyramid of Xs on the screen. The
pyramid should look like this
except that it should be 20 lines high, instead of the 5 lines shown here. One way to do this is to
nest two inner loops, one to print spaces and one to print Xs, inside an outer loop that steps
down the screen from line to line.
Expert's answer
#include <iostream> using namespace std;
void main()
for (int i= 0; i < 20; i++) // for i = 0 to i < 20
for(int j = 0; j <= i; j++) // for j = 0 to j <= i
cout<< "X"; // print X
cout<< endl; // print end of line

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions