#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n, a, b;
cout<<"enter the number of lines : ";
cin>>n;
a=((n/2)+1);
b=n-a;
for(int i=1 ; i<=a ; i++)
{
for(int j=1 ; j<=a-i ; j++)
cout<<" ";
for(int k=1 ; k<=i ; k++)
cout<<"*";
for(int l=2 ; l<=i ; l++)
cout<<"*";
cout<<"\n";
}
int c=b+1;
// int d=b-1;
for(int p=1; p<=b ; p++)
{
for(int q=1 ; q<=p ; q++)
cout<<" ";
for(int s=1 ; s<=c-p ; s++)
cout<<"*";
for(int r=1 ; r<=b-p ; r++)
cout<<"*";
cout<<"\n";
}
getch();
}
.................................................................
OUTPUT :(click to enlarge the image)
No comments:
Post a Comment