Decrease Character Pyramid Posted: 29 Jan 2014 04:10 AM PST Q. Write a C program to print the following decrease character pyramid as: EEEEEDDDDCCCBBA Ans. /*c program for decrease number pyramid*/#include<stdio.h>int main(){ char ch,p,r,c; printf("Enter any character : "); scanf("%c", &ch); if(ch>='a' && ch<='z') ch=ch-32; p=ch; for(r='A'; r<=ch; r++,p--) { for(c='A'; c<=p; c++) printf("%c",p); printf("\n"); } getch(); return 0;} /**************************************************************The output of above program would be: ***************************************************************/
| Figure: Screen shot for decrease character pyramid C program |
|
Post a Comment