Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- //if user entered D, output should be as follows:
- //A
- //ABA
- //ABCBA
- //ABCDCBA
- int main()
- {
- char ch,tch;
- int i,j;
- scanf("%c",&ch);
- for(i=0;i<=ch-'A';i++) //number of strings
- {
- tch= 'A'-1;
- for(j=0;j<i+1;j++) //letters in ascending order
- {
- printf("%c",++tch);
- }
- for(j=0;j<i;j++) //letters in descending order
- {
- printf("%c",--tch);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement