ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# C 程序:检查字母是元音还是辅音 > 原文: [https://beginnersbook.com/2017/09/c-program-to-check-whether-an-alphabet-is-vowel-or-consonant/](https://beginnersbook.com/2017/09/c-program-to-check-whether-an-alphabet-is-vowel-or-consonant/) 该程序检查输入字符是元音还是辅音。 ## 示例:用于检查元音或辅音的程序 此程序将字符值(由用户输入)作为输入,并使用`if-else`语句检查该字符是否为元音或辅音。由于允许用户以小写和大写形式输入字母,因此程序检查大写和小写元音和辅音。要理解该程序,您应该熟悉以下 [C 编程](https://beginnersbook.com/2014/01/c-tutorial-for-beginners-with-examples/)概念: 1. [C 编程`if`语句](https://beginnersbook.com/2014/01/c-if-statement/) 2. [C 编程`if..else`语句](https://beginnersbook.com/2014/01/c-if-else-statement-example/) ```c #include <stdio.h> int main() { char ch; bool isVowel = false; printf("Enter an alphabet: "); scanf("%c",&ch); if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I' ||ch=='o'||ch=='O'||ch=='u'||ch=='U') { isVowel = true; } if (isVowel == true) printf("%c is a Vowel", ch); else printf("%c is a Consonant", ch); return 0; } ``` 输出: ```c Enter an alphabet: E E is a Vowel ``` 看看这些相关的 C 程序: 1. [C 程序:将小写字符串转换为大写](https://beginnersbook.com/2015/02/c-program-to-convert-lowercase-string-to-uppercase-string/) 2. [C 程序:将大写字符串转换为小写](https://beginnersbook.com/2015/02/c-program-to-convert-uppercase-string-to-lowercase-string/) 3. [C 程序:查找字符的 ASCII 值](https://beginnersbook.com/2017/09/c-program-to-find-ascii-value-of-a-character/) 4. [C 程序:在不使用预定义函数的情况下连接两个字符串](https://beginnersbook.com/2015/02/c-program-to-concatenate-two-strings-without-using-strcat/) 5. [C 程序:在不使用`strlen` 的情况下查找字符串的长度](https://beginnersbook.com/2015/02/c-program-to-find-the-length-of-a-string/)