Answer to Question #191128 in C++ for python

Question #191128

print an inverted pyramid by using for loop structure and 'setw' manipulator.


1
Expert's answer
2021-05-11T23:18:02-0400
#include <iostream>
#include <iomanip>


using namespace std;


void getPyramid(int number){
    int n = 0;
	for(int m = 1; m < number; m++)
	{
		cout << setw(m + 5);
		for(int i = n ; i < number - n; i++)
			cout << number - i ;
		cout << endl;
		n++;
	}
}
int main()
{
	int num;
	cout << "Enter a number: ";
	cin >> num;
	getPyramid(num);
	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