Write a C program to check whether an alphabet is Vowel or Consonant
Description:
You need to create a C program to check whether an alphabet is Vowel or Consonant.
Conditions:
- Create a character type variable with name of alphabet and take the value from the user.
- You can use conditional statements.
#include <stdio.h>
int main()
{
char alphabet;
printf("Enter an alphabet: ");
scanf("%c", &alphabet);
if (alphabet == 'a' || alphabet == 'A')
{
printf("%c is a vowel.", alphabet);
}
else if (alphabet == 'e' || alphabet == 'E')
{
printf("%c is a vowel.", alphabet);
}
else if (alphabet == 'i' || alphabet == 'I')
{
printf("%c is a vowel.", alphabet);
}
else if (alphabet == 'o' || alphabet == 'O')
{
printf("%c is a vowel.", alphabet);
}
else if (alphabet == 'u' || alphabet == 'U')
{
printf("%c is a vowel.", alphabet);
}
else
{
printf("%c is a consonant.", alphabet);
}
return 0;
}
Tutorials Class - Output Window
Enter an alphabet: O
O is a vowel.
Learn more about the similar topics:
Tutorials |
---|
No Content Found. |
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
No Content Found. |