Q. How to design a character triangle shape C program as:
ABCDE
ABCD
ABC
AB
A
Ans.
/*Character Triangle Shape C Program*/
#include<stdio.h>
int main()
{
int n=1;
char r,c,ch;
printf("Entery any character : ");
scanf("%c", &ch);
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++,n++)
{
for(c='A'; c<=ch-n+1; c++)
printf("%c", c);
printf("\n");
}
getch();
return 0;
}
You might also like related programs:
ABCDE
ABCD
ABC
AB
A
Ans.
/*Character Triangle Shape C Program*/
#include<stdio.h>
int main()
{
int n=1;
char r,c,ch;
printf("Entery any character : ");
scanf("%c", &ch);
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++,n++)
{
for(c='A'; c<=ch-n+1; c++)
printf("%c", c);
printf("\n");
}
getch();
return 0;
}
/**********************************************
The output of above program would be:
************************************************/
Figure: Screen shot for Character Triangle Shape C Program |
You might also like related programs:
No comments:
Post a Comment