Output:
Enter Size : 7
*
***
*****
*******
* *
*** ***
***** *****
******* *******
Code:
#include<iostream>
using namespace std;
int main()
{
int n,i,j,k;
cout<<"Enter Size : ";
cin>>n;
if(n%2!=0)
n++;
cout<<"\n\t";
for(i=1;i<=(n+1)/2;i++)
{
for(j=n;j>=i;j--)
cout<<" ";
for(k=1;k<=2*i-1;k++)
cout<<"*";
cout<<"\n\t";
}
for(i=(n+2)/2;i<=n;i++)
{
for(j=n;j>=i;j--)
cout<<" ";
for(k=n+1;k<=(2*i-1);k++)
cout<<"*";
for(j=i;j<=(2*n-i);j++)
cout<<" ";
for(k=n+1;k<=(2*i-1);k++)
cout<<"*";
cout<<"\n\t";
}
}