Question #13553

Write a C program to display the following number triangle structure:

54321
4321
321
21
1

Expert's answer

#include<stdio.h>
int main()
{
int num,r,c,sp;
printf("Enter
number of rows: ");
scanf("%d", &num);
for(r=1; r<=5;
r++,num--)
{
for(sp=r; sp>1; sp--)
printf(" ");
for(c=num;
c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
return
0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS