#include<iostream.h>
#include<conio.h>
void main()
{
int ch,i,j,in=1;
char ans='y';
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5-i&&i<=3;j++)
cout<<"\t"; //to leave space before stars for upper triangle
for(j=1;j<=i-1&&i>3;j++) //to leave space before stars for lower triangle
cout<<"\t";
for(j=1;j<=in;j++) //to display stars
cout<<"*\t";
if(i+1<=3)
in=in+2; //to decide no of stars in each row
else
in=in-2;
cout<<"\n\n";
}
getch();
}
#include<conio.h>
void main()
{
int ch,i,j,in=1;
char ans='y';
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=5-i&&i<=3;j++)
cout<<"\t"; //to leave space before stars for upper triangle
for(j=1;j<=i-1&&i>3;j++) //to leave space before stars for lower triangle
cout<<"\t";
for(j=1;j<=in;j++) //to display stars
cout<<"*\t";
if(i+1<=3)
in=in+2; //to decide no of stars in each row
else
in=in-2;
cout<<"\n\n";
}
getch();
}
0 comments:
Post a Comment