Browse Source

Next prog. exercise of chapter 06

master
T. Meissner 9 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 @@
#include <stdio.h>
int main(void) {
char letter;
printf("Give an uppercase char: ");
scanf("%c", &letter);
if (letter < 'A' || letter > 'Z') {
printf("ERROR: No uppercase char\n");
return 1;
}
for (char i = 'A'; i <= letter; i++) {
for (char a = letter - i; a > 0; a--) {
printf(" ");
}
for (char b = 'A'; b <= i ; b++) {
printf("%c", b);
}
for (char c = i - 1; c >= 'A' ; c--) {
printf("%c", c);
}
printf("\n");
}
return 0;
}

Loading…
Cancel
Save