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("\n");
}
getch();
return 0;
}
/**************************************************************
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("\n");
}
getch();
return 0;
}
/**************************************************************
The output of above program would be:
***************************************************************/Figure: Screen shot for decrease character pyramid C program |
0 komentar:
Post a Comment