Pyramid Problem No. 48
Q. 48 Write a C program to print the following number pyramid:
1
222
33333
4444444
555555555Solving in C:#include <stdio.h> int main(){ int row,col; for(row=1; row<=5; row++){ for(col=1; col<=5-row; col++) printf(" ",col); for(col=1; col<=2*row-1; col++) printf("%d ",row); printf("\n"); } return 0; }
Comments
Post a Comment