program for print pyramid
#include<stdio.h>
void main()
{
int x=1,a,n=1,i=0;
printf("enter how long print pyramid");
scanf("%d",&a);
printf("%2d",x);
printf("\n");
while(n<a)
{
i=0;
while(i<=n)
{
x=x+1;
printf("%2d",x);
i++;
}
printf("\n");
n++;
}
}
void main()
{
int x=1,a,n=1,i=0;
printf("enter how long print pyramid");
scanf("%d",&a);
printf("%2d",x);
printf("\n");
while(n<a)
{
i=0;
while(i<=n)
{
x=x+1;
printf("%2d",x);
i++;
}
printf("\n");
n++;
}
}
Comments
Post a Comment