Program in C to print the number pyramid


Write a C program to print the following number pyramid as:

1234
2341
3412
4123

Solution:
#include<stdio.h>
int main()
{
int num,n,r,c,t;
printf("Enter any number : ");
scanf("%d", &num);
for(r=1; r<=num; r++)
{
for(c=r; c<=num; c++)
printf("%d",c);
for(t=1; t<r; t++)
printf("%d",t);
printf("\n");
}
return 0;
}



Post a Comment