Write a C program to print the following character pyramid as:
ABCD
BCDA
CDAB
DABC
Solution:
Solution:
#include<stdio.h>
int main()
{
char ch,r,c,t;
printf("Enter any character : ");
scanf("%c", &ch);
if(ch>='a' && ch<='z')
ch = ch - 32;
for(r='A'; r<=ch; r++)
{
for(c=r; c<=ch; c++)
printf("%c",c);
for(t='A'; t<r; t++)
printf("%c",t);
printf("\n");
}
return 0;
}
Post a Comment