Write a value-returning function, isVowel, that returns the value true if a given character is a vowel, and otherwise returns false. Explain your code.
#include <stdio.h>
//This function allows to check if the character is vowel
int isVowel(char ch){
if ((ch == 'A') || (ch == 'E')|| (ch == 'I')|| (ch == 'O')|| (ch == 'U')|| (ch == 'a')|| (ch == 'e')||
(ch == 'i')|| (ch == 'o')|| (ch == 'u')) {
return 1;//return true
}
else {
return 0;//return false
}
}
int main() {
char character;
//read character from the keyboard
printf("Enter character: ");
scanf("%c",&character);
//check if the character is vowel
if(isVowel(character)==1){
printf("%c is a vowel\n",character);
}else{
printf("%c is NOT a vowel\n",character);
}
//delay
getchar();
getchar();
return 0;
}
Comments
Leave a comment