1
**
123
****
12345
******
Ans.
/* c program for number star pyramid */
#include<stdio.h>
int main()
{
int num=6,r,c;
for(r=1; r<=num; r++)
{
for(c=1; c<=r; c++)
{
if(r%2==0)
printf("*");
else
printf("%d",c);
}
printf("\n");
}
getch();
return 0;
}
The output of above program would be:
Figure: Screen shot for number-star pyramid C program |
No comments:
Post a Comment