Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
506 B

  1. #include <stdio.h>
  2. int main(void) {
  3. char letter;
  4. printf("Give an uppercase char: ");
  5. scanf("%c", &letter);
  6. if (letter < 'A' || letter > 'Z') {
  7. printf("ERROR: No uppercase char\n");
  8. return 1;
  9. }
  10. for (char i = 'A'; i <= letter; i++) {
  11. for (char a = letter - i; a > 0; a--) {
  12. printf(" ");
  13. }
  14. for (char b = 'A'; b <= i ; b++) {
  15. printf("%c", b);
  16. }
  17. for (char c = i - 1; c >= 'A' ; c--) {
  18. printf("%c", c);
  19. }
  20. printf("\n");
  21. }
  22. return 0;
  23. }