Pyramid Problem No. 61

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

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

Solving in C:

#include <stdio.h>
    int main(){
        int row,col,row_count;
        for(row=1; row<=5; row++){
            for(col=1; col<row; col++)printf(" ");
            for(col=5-row+1,row_count=row; col>=1; col--) printf("%d ",row_count++);
            printf("\n");
        }
        return 0;
    }

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85