Pyramid Problem No. 24
Q.24 Write a C program to print following character triangle:
A B C D E D C B A
B C D E D C B
C D E D C
D E D
ESolving in C:#include <stdio.h> int main(){ int row,col,count; for(row=5;row>=1;row--){ for(col=5,count=65;col>=1;col--,count++){ if(row>=col) printf("%c ",count); else printf(" "); } for(col=1,count=64+5-1; col<=row-1; col++) printf("%c ",count--); printf("\n"); } return 0; }
Comments
Post a Comment