Pyramid Problem No. 25

 Q.25 Write a c program for the following number structure:

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

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");
    	    }
    	    for(row=5-1;row>=1;row--){
    	        for(col=row;col>=1;col--) printf("%d ",row);
    	        printf("\n");
    	    }
    	    return 0;
        }

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85