===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
int n,i,j,k,b;
cout<<"Enter number: ";
cin>>n;
b=n-1;
clrscr();
for(i=1;i<=n;i++)
{
for(k=1;k<=b;k++)
cout<<" ";
for(j=1;j<=i;j++)
{
if(j==1 || i==n || j==i)
cout<<"* ";
else
cout<<" ";
}
b=b-1;
cout<<"\n";
}
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
int n,i,j,k,b;
cout<<"Enter number: ";
cin>>n;
b=n-1;
clrscr();
for(i=1;i<=n;i++)
{
for(k=1;k<=b;k++)
cout<<" ";
for(j=1;j<=i;j++)
{
if(j==1 || i==n || j==i)
cout<<"* ";
else
cout<<" ";
}
b=b-1;
cout<<"\n";
}
getch();
}
===========================================================================
No comments:
Post a Comment