Hi there, right now my teacher wants me to make an outline of a half-diamond with numbers, using for loops, kind of like the following:
1
2
3
4
5
4
3
2
1
The number 5 is a user input, so the half-diamond's width would be controlled by the user. I really don't know how to do this and would kindly request some help!
Right now my code looks like the following:
void fifthFunction(int number)
{
const char SPACE = ' ';
for(int counter = 0; counter <= number; counter++){
for(int spaces = 0; counter > 0 && counter < number; spaces)
cout << SPACE;
for(int row = 1; row <= number; row++)
cout << row;}
cout << endl;
}
To be honest, I really don't know what I'm doing with this problem and it's really stumping me. Any advice or help would be appreciated!