The below program is to print the Alphabet Triangle in C using loop.
C program to print Alphabet Triangle
#include <stdio.h> #include<stdlib.h> void main() { int alpha=97; int i,j,k,m; for(i=1; i<=5; i++) { for(j=5; j>=i; j--) printf(" "); for(k=1; k<=i; k++) printf("%c",alpha++); alpha--; for(m=1; m<i; m++) printf("%c",--alpha); printf("\n"); alpha=97; } } |
Output
a aba abcba abcdcba abcdedcba |