C语言练习:打印出26个英文字母.根据用户需要打印出大写和小写
#include <stdio.h> int main() { char c; printf("Enter u to display uppercase alphabets.\n"); printf("Enter l to display lowercase alphabets. \n"); scanf("%c", &c); if (c == 'U' || c == 'u') { for (c = 'A'; c <= 'Z'; ++c) printf("%c ", c); } else if (c == 'L' || c == 'l') { for (c = 'a'; c <= 'z'; ++c) printf("%c ", c); } else { printf("Error! You entered an invalid character."); } return 0; }
结果:
Enter u to display uppercase alphabets.
Enter l to display lowercase alphabets. l
a b c d e f g h i j k l m n o p q r s t u v w x y z
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!