68.2k views
3 votes
Write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. For the input E, your output should look like the following: E is a vowel: 1 When printing the value of a bool, true will be displayed as 1 and false will be displayed as 0. Grading When you have completed your program, click the Submit button to record your score.

User Onnonymous
by
8.7k points

1 Answer

4 votes

Answer:

Step-by-step explanation:

C++ Code

#include<iostream> //for input and output

using namespace std;

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 true;

}

else {

return false;

}

}

int main()

{

char character;

cout<<"Enter character : ";

cin >> character;

cout<<character<< " is a vowel:"<<isVowel(character);

return 0;

}

Code Explanation

Get character from user and pass that character into isVowel function.

IsVowel function then check if the character is vowel by using if statement.

if character is vowel the return true as a Boolean value.

By using Cout, Boolean value then converted into number. so it will show 1 for true and 0 for false.

Output

Case 1:

Enter character : a

a is a vowel:1

Case 2:

Enter character : b

b is a vowel:0

User Joanna Derks
by
8.1k points