+ 2
Program to print this
& & & & & & & Howwwww?????????
2 Answers
+ 2
You'll need to use a nested for loop:
int rows;
cout << "Enter how high you want the pyramid to be: ";
cin >> rows;
int columns = (rows * 2) - 1;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
if (j == (rows - i - 1) || j == (rows + i - 1))
cout << "&";
else
cout << " ";
}
cout << endl;
}
try this and see if it works...I haven't actually tested it; i just wrote is right here haha. and if it doesn't work, you can fix it, I'm sure!
- 1
i don't know