Q. Write a C program to print the following star pyramid structure:
*********
*******
*****
***
*
Ans.
/*c program for star pyramid design*/
#include<stdio.h>
int main()
{
int n=9,r,c;
for(r=5; r>=1; r--,n=n-2)
{
for(c=1; c<=n; c++)
printf("*");
printf("\n");
}
return 0;
}
The output of above program would be:
*********
*******
*****
***
*
Ans.
/*c program for star pyramid design*/
#include<stdio.h>
int main()
{
int n=9,r,c;
for(r=5; r>=1; r--,n=n-2)
{
for(c=1; c<=n; c++)
printf("*");
printf("\n");
}
return 0;
}
The output of above program would be:
Figure: Screen shot for star triangle C program |
Comments
Post a Comment