Pyramid Problem No. 85

 Q.85 Design the following number pyramid:

1
121
1231
12341
123451

Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74