I'm writing a C++ program that will print a diamond filled with *'s, with the size of the diamond to be detemined by the user. This is what I'm try to get:
*
***
*****
*******
*****
***
*
But my code gives me this:
*****
****
***
**
*
Here's my code:
//diamond_of_asterisks
cout << "Enter size n (1 to 80):" <<endl;
cin >> n;
for (int k = 1; k <=5; ++k)
{
cout << setw(k) << ' ';
for (int j =k; j <= 5; ++j;
cout << '*';
cout << endl;
I can't seem to complete the diamond. Can anyone help me? Thanks!