dimond

i made programme to print a hollow dimond of star.but i made it with 6 loops.now i want to make it with 2 or 3 loops..helpppppp me.how i can made it??
Show your current version.
#include<iostream>
using namespace std;
int main()
{
int n;

cout<<"Enter a number: ";

cin>>n;

for (int y = 1; y <=n; y++)
{

for(int z=n-y;z>0;z--)
{
cout<<" ";
}
for(int x = 1; x <=y; x++)
{
cout<<"*"<<" ";
}

cout<<endl;

}
for (int y = n-2; y >=0; y--)
{

for(int z=n-(y+1);z>0;z--)
{
cout<<" ";
}
for(int x = y; x >=0; x--)
{
cout<<"*"<<" ";
}

cout << endl;
}

return 0;
}
Things to consider:
1. How many rows there are in total in the diamond?
2. std::abs(n-row)
3. std::setw
Topic archived. No new replies allowed.