Pyramid Problem No. 32

 Q.32 Write a C program to print the following number pyramid:

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

Solving in C:

    #include <stdio.h>
    int main(){
        int row,col;
        for(row=1;row<=6;row++){
            for(col=5;col>=row;col--) printf(" ");
            for(col=1;col<=row;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