Program to print Pyramid of stars:
#include<stdio.h>
void main()
{
int i,j;
j=1;
while(j<=6)
{
i=1; //*******
while(i<=7) //*******
{ //*******
printf("*"); //*******
i=i+1;
}
printf("\n");
j=j+1;
}
printf("\n Different Pyramid\n");
j=1;
while(j<=6)
{
i=1;
while(i<=j)
{
printf("*");
i=i+1;
}
printf("\n");
j=j+1;
}
printf("\n Different Pyramid\n");
j=6;
while(j>=1)
{
i=1;
while(i<=j)
{
printf("*");
i=i+1;
}
printf("\n");
j=j-1;
}
}
Output:
void main()
{
int i,j;
j=1;
while(j<=6)
{
i=1; //*******
while(i<=7) //*******
{ //*******
printf("*"); //*******
i=i+1;
}
printf("\n");
j=j+1;
}
printf("\n Different Pyramid\n");
j=1;
while(j<=6)
{
i=1;
while(i<=j)
{
printf("*");
i=i+1;
}
printf("\n");
j=j+1;
}
printf("\n Different Pyramid\n");
j=6;
while(j>=1)
{
i=1;
while(i<=j)
{
printf("*");
i=i+1;
}
printf("\n");
j=j-1;
}
}
Output:
Comments
Post a Comment