/*
* 1000+ C programs + tutorials
*
*
* 40_check_entered_char_is_a_vowel_or_consonant.c
*
*
* Created on: Oct 20, 2014
* Author: Code2care.org
*/
#include
//#include
void main() {
char ch;
//clrscr();
printf("C Program to Find Entered Character is a Vowel or Consonant.");
printf("\n\n Enter Number : ");
scanf("%c", &ch);
//Logic to find Vowel/Consonant
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' ) {
printf("\n\n %c is a Vowel!! ",ch);
}
else {
printf("\n\n %c is a Consonant!! ",ch);
}
// getch();
}
-
Output :
C Program to Find Entered Character is a Vowel or Consonant.
Enter Number : a
a is a Vowel!!
C Program to Find Entered Character is a Vowel or Consonant.
Enter Number : c
c is a Consonant!!
Using Switch-Case
/*
* 1000+ C programs + tutorials
*
*
* 40_check_entered_char_is_a_vowel_or_consonant.c
*
* Using Switch-Case
*
* Created on: Oct 20, 2014
* Author: Code2care.org
*/
#include
//#include
void main() {
char ch;
//clrscr();
printf("C Program to Find Entered Character is a Vowel or Consonant.");
printf("\n\n Enter Number : ");
scanf("%c", &ch);
//Logic to find Vowel/Consonant
switch(ch) {
case 'a' || 'e' || 'i' || 'o' || 'u' :
printf("\n\n %c is a Vowel!! ",ch);
break;
case 'A' || 'E' || 'I' || 'O' || 'U' :
printf("\n\n %c is a Vowel!! ",ch);
break;
default:
printf("\n\n %c is a Consonant!! ",ch);
}
// getch();
}
-
Output :
C Program to Find Entered Character is a Vowel or Consonant.
Enter Number : a
a is a Vowel!!
C Program to Find Entered Character is a Vowel or Consonant.
Enter Number : c
c is a Consonant!!
The best way to learn C programming is to practice more and more of programs .
Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.
BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.