Answer:
This function returns a Boolean value in the form of Boolean variable which shows whether the parameter is a vowel or not.
return result;
The c++ program for the above is given which shows the output in the given format.
#include <stdio.h>
#include <iostream>
using namespace std;
bool isVowel(char c);
bool isVowel(char c)
c == 'i'
int main() {
char data;
cout<<"This program will check if the entered character is a vowel."<<endl;
cout<<"Enter any alphabet"<<endl;
cin>>data;
cout<<endl<<data <<" is a vowel: "<<isVowel(data)<<endl;
return 0;
}
OUTPUT
This program will check if the entered character is a vowel.
Enter any alphabet
o
o is a vowel: 1
Step-by-step explanation:
The function which accepts an alphabet and returns a value is shown below.
bool isVowel(char c)
The function isVowel() accepts an alphabet which is stored in a character variable and returns a Boolean value.
bool isVowel(char c)
This function declares a Boolean variable, result, and initializes it to false.
bool result=false;
The parameter is matched will all the vowels in both lower case and upper case. If the character matches, i.e., if it is a vowel, the Boolean variable is initialized to true. If the alphabet does not matches, there is no change in the value of Boolean variable result, i.e., result holds the value false.
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c =='E' || c =='I' || c =='O' || c =='U')
result = true;