Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ program. Write a value-returning function, isVowel , that returns the value

ID: 3857199 • Letter: C

Question

C++ program. Write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false.

***Collect the user's input in the main() and pass it to the isVowel() function. isVowel() function returns true or false.

***Use Call-by-Value (value returning function).

***Validate the user's input (allow only alphabet characters: a through z, or A through Z).

***Allow the user to repeat the program.

OUTPUTS:

**************************************************************************************

Enter an alphabet character: 2

Invalid input.

Please try again.

Enter an alphabet character:

**********************************

Enter an alphabet character : a

a is a vowel: 1

Do you want to repeat this program?
y/n
> y

**********************************

Enter an alphabet character : E

E is a vowel: 1

Do you want to repeat this program?
y/n
> y

**********************************

Enter an alphabet character : B

B is a vowel: 0

Do you want to repeat this program?
y/n
> n

Explanation / Answer

// please like the answer,,if u find it useful
#include <iostream>
using namespace std;

bool isvowel(char c)
{
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
{
return true;
}
else
{
return false;
}
}

int main()
{
char c,b;
while(1)
{
cout << " Enter an alphabet character : ";
cin >> c;

if( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
{
bool result = isvowel(c);
cout <<" "<< c << " is a vowel : "<< result<<endl;
cout <<" Do you want to repeat this program ( y/n) : ";
cin >> b;
if(b == 'n' || b == 'N')
{
break;
}
}
else
{
cout << " Invalid input ";
cout << " Please Try again ";
}
}
return 0;
}



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote