Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

vowel and consonant C

//vowel or consonant check program in C using only the if
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char letter;

    printf("Enter a letter: 
");
    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
", letter);
        }
        else
        {
            printf("The letter that you have entered (%c) is a consonant
", letter);
        }
    }
    else
    {
        printf("You didn't enter any letter
");
    }
    system("pause");
    return 0;
}
 
PREVIOUS NEXT
Tagged: #vowel #consonant #C
ADD COMMENT
Topic
Name
9+2 =