Pyramid Problem No. 28
Q.28 Write a C program to display the following number triangle:
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Solving in C:#include <stdio.h> int main(){ int row,col; for(row=1;row<=5;row++){ for(col=1;col<=row;col++) printf("%d ",row); printf("\n"); } return 0; }
Comments
Post a Comment