Decrease Character Pyramid

Friday, April 11, 2014

Q. Write a C program to print the following decrease character pyramid as:

EEEEE
DDDD
CCC
BB
A

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("
"
);

 }
 getch();
 return 0;
}

/**************************************************************
The output of above program would be:
***************************************************************/


Output for decrease character pyramid C program
Figure: Screen shot for decrease character pyramid C program

Related Posts by Categories

0 comments:

Post a Comment

Copyright © 2014 Information Sharing | Powered By Blogger