Pyramid Problem No. 47

 Q. 47 Write a C program for print the following character pyramid:

ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA

Solving in C:

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

Comments

Popular posts from this blog

Pyramid Problem No. 90

Pyramid Problem No. 74

Pyramid Problem No. 85