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