Pyramid Problem No. 60
Q. 60 Write a C program to print the following Floyd triangle as:
1
2 3
4 5 6
7 8 9 10Solving in C:
#include <stdio.h>
int main(){
int row,col,count=1;
for(row=4; row>=1; row--){
for(col=1; col<=row; col++) printf(" ");
for(col=1; col<=4-row+1; col++) printf("%d ",count++);
printf("\n");
}
return 0;
}
Comments
Post a Comment