Answer to Question #289974 in C++ for ali

Question #289974

 Use for loops to construct a program that displays a pyramid of Xs on the screen. The pyramid should look like: X X X X X X X X X X X X X X X


1
Expert's answer
2022-01-30T02:56:41-0500


#include <iostream>
#include <conio.h>
using namespace std;


int main()
{
	int i, j, k, c=5;
	for(i=1;i<=5;i++)
	{
		for(k=1;k<c;k++)
		{
			cout<<" ";
		}
		for(j=1;j<=(2*i)-1;j++)
		{
			cout<<"X";
		}
		cout<<endl;
		c--;
	}


	system("pause");
	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
New on Blog