Code:
#include<iostream>
using namespace std;
int main()
{
int n;
cout<<" Enter Number of Rows : ";
cin>>n;
cout<<"\n\n";
int i,j,k;
for(i=1;i<=n+1;i++)
{
cout<<" ";
}
cout<<"*\n";
for(i=1;i<=n;i++)
{
for(j=n;j>=i;j--)
{
cout<<" ";
}
cout<<"*";
for(k=0;k<(2*i-1);k++)
{
printf(" ");
}
cout<<"*\n";
}
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<" ";
}
cout<<"*";
for(k=(2*i-1);k<=(2*n-1);k++)
{
cout<<" ";
}
cout<<"*\n";
}
for(i=0;i<=n;i++)
{
cout<<" ";
}
cout<<"*";
}
Output:
Enter Number of Rows : 7
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*