Advertisement
Lisaveta777

Prata ch 6 exs 5

Aug 16th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. //if user entered D, output should be as follows:
  4. //A
  5. //ABA
  6. //ABCBA
  7. //ABCDCBA
  8.  
  9. int main()
  10. {
  11.     char ch,tch;
  12.     int i,j;
  13.     scanf("%c",&ch);
  14.  
  15.     for(i=0;i<=ch-'A';i++) //number of strings
  16.     {
  17.         tch= 'A'-1;
  18.  
  19.         for(j=0;j<i+1;j++) //letters in ascending order
  20.         {
  21.             printf("%c",++tch);
  22.         }
  23.  
  24.         for(j=0;j<i;j++) //letters in descending order
  25.         {
  26.             printf("%c",--tch);
  27.         }
  28.  
  29.         printf("\n");
  30.  
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement