Pyramid Problem No. 50

 Q. 50 Write a C program to print the following number triangle:

 5
 45
 345
 2345
 12345

Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85