Pyramid Problem No. 81

 Q.81 Print continue character number pyramid as:

1
A B
2 3 4
C D E F
5 6 7 8 9

Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85