C Program To Display Inverted Half Triangle of Alphabets (Pattern)
C Program :
/* Aim: Write a program to display output as follows: A B C D A B C A B A */ #include <stdio.h> #include <stdlib.h> void main() { int c,a,e,n,l,num; printf("\n How many lines:- "); scanf("%d",&n); printf("\n"); if ((n>26) || (n<=0)) { printf("\n Error:You can specify only 26 lines. please specify a numeric value \n \n"); exit(1); } for (l=n;l>=1;l--) { e=64+l; for (num=65;num<=e;num++) printf("%c\t",num); printf("\n"); } printf("\n"); } // End of the code
/* Output of above code:
[root@ugilinux ~]# gcc -o e5a3 e5a3.c
[root@ugilinux ~]# ./e5a3
How many lines:- 4
A B C D
A B C
A B
A
*/