原文: https://beginnersbook.com/2017/09/c-program-to-check-whether-an-alphabet-is-vowel-or-consonant/
该程序检查输入字符是元音还是辅音。
此程序将字符值(由用户输入)作为输入,并使用if-else
语句检查该字符是否为元音或辅音。由于允许用户以小写和大写形式输入字母,因此程序检查大写和小写元音和辅音。要理解该程序,您应该熟悉以下 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;
}
输出:
Enter an alphabet: E
E is a Vowel
看看这些相关的 C 程序: