8.08.2015

Character Triangle Shape C Program

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;
}


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


Output of Character Triangle Shape C Program
Figure: Screen shot for Character Triangle Shape C Program


You might also like related programs:

  1. Big 98+ C Pyramid programs list
  2. Latest user asking pyramid programs list

No comments:

Post a Comment