Browse Source

Next prog. exercise of chapter 06

T. Meissner 4 years ago
parent
commit
46bd1bc3a6
1 changed files with 32 additions and 0 deletions
  1. 32
    0
      c_primer_plus/chapter06/05.c

+ 32
- 0
c_primer_plus/chapter06/05.c View File

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