Pyramid Problem No. 84

 Q.84 Print the following number design:

 1
 23
 4
 56
 7
 89
 10


Solving in C:

#include <stdio.h>
    int main(){
        int n=7,row,col,count=1;
        for(row=1; row<=n; row++){
            for(col=1;row%2==1 && col<=1; col++) printf("%d",count++);
            for(col=1; row%2==0 && col<=2; 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