Pyramid Problem No. 51
Q. 51 Write a C program to print the following number triangle:
5
454
34543
2345432
123454321
Solving in C:
#include <stdio.h>
int main(){
int row,col,count;
for(row=5; row>=1; row--){
for(col=1,count=row; col<=5-row+1; col++) printf("%d",count++);
for(col=1,count-=1; col<=5-row; col++) printf("%d",--count);
printf("\n");
}
return 0;
}
Comments
Post a Comment