📌  相关文章
📜  元音和辅音 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:44.380000             🧑  作者: Mango

代码示例2
//vowel or consonant check program in C using only the if
#include 
#include 

int main()
{
    char letter;

    printf("Enter a letter: \n");
    scanf("%c", &letter);

    if (letter >= 65 && letter <= 90 || letter >= 97 && letter <= 122) //this line check if you have entered a letter based on the ascii chart
    {
        if (letter == 'a' || letter == 'A' || letter == 'e' || letter == 'E' || letter == 'i' || letter == 'I' || letter == 'o' || letter == 'O' || letter == 'u' || letter == 'U')
        {
            printf("The letter that you have entered (%c) is a vowel\n", letter);
        }
        else
        {
            printf("The letter that you have entered (%c) is a consonant\n", letter);
        }
    }
    else
    {
        printf("You didn't enter any letter\n");
    }
    system("pause");
    return 0;
}