Simply pass the argument n as needed by you and call the function as and when needed.
Happy programming..
void print(int n)
{ int j,k,sp=18;
for(int i=1;i
{ for(k=1;k<=sp;k++)
{
cout<<" ";
} sp-=2;
for(j=1;j<=2*i-1;j++)
{
cout<<"* ";
}
cout<<"\n";
}
sp+=2;
for(int i=n-1;i>0;i--)
{ sp+=2;
for(int l=1;l<=sp;l++)
{ cout<<" ";
}
for(int j=2;j<2*i-1;j++)
{
cout<<"* ";
}
cout<<"\n";
}
*
***
*****
*******
*****
***
*
No comments:
Post a Comment
Your comment may wait for moderation....