pyramidpatternnestedloop
pyramidpatternnestedloop
int main() {
int n;
cout << "Enter the number of rows for the pyramid: ";
cin >> n;
} else {
return 0;
The program asks the user to input the number of rows for the pyramid.
The outer loop runs from 1 to n, representing each row of the pyramid.
The inner loop runs from 1 to 2 * n - 1, representing the number of columns in each row.
The condition column >= n - (row - 1) && column <= n + (row - 1) checks if the
current column should print a * or a space.
The pyramid is symmetrical, so the condition ensures that * is printed in the middle section,
while spaces are printed on either side.