Check Vowel or Consonant in C program to using if else
Check Vowel or Consonant in C program to using if else. we check whether it is a vowel or a consonant.
1 |
#include <stdio.h> int main(){ char ch; printf("Input a character\n"); scanf("%c", &ch); if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' &&ch <= 'Z')) { if (ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch== 'u' || ch=='U') printf("%c is a vowel.\n", ch); else printf("%c is a consonant.\n", ch); } else printf("%c is neither a vowel nor a consonant.\n", ch); return 0;}</stdio.h> |
1 |
#include <stdio.h> int main(){ char ch; printf("Enter a character\n"); scanf("%c", &ch); if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U') printf("%c is a vowel.\n", ch); else printf("%c is not a vowel.\n", ch); return 0;}</stdio.h> |