Question

Write a program that write a value-returning function, isVowel, that returns the value true if a...

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

You must insert the following comments at the beginning of your program and write our commands in the middle:

Write a C++ Program:

/*

// Name: Your Name

// ID: Your ID

*/

using namespace std;

#include <iostream>

using namespace std;

bool isVowel(char ch);

int main()

{

    char ch;

    …

    …

         YOUR CODE HERE

  …

    …

return 0;

}

bool isVowel(char ch)

{

    switch (ch)

    …

    …

         YOUR CODE HERE

  …

    …

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using namespace std;

#include <iostream>

using namespace std;

bool isVowel(char ch);

int main()

{

char ch;
cout<<"Enter character: ";
cin>>ch;
if(isVowel(ch))
cout<<"Vowel"<<endl;
else
cout<<"Consonants"<<endl;

return 0;

}

bool isVowel(char ch)

{

switch (ch)
{
case 'a': return true;
break;
case 'e': return true;
break;
case 'i': return true;
break;
case 'o': return true;
break;
case 'u': return true;
break;
case 'A': return true;
break;
case 'E': return true;
break;
case 'I': return true;
break;
case 'O': return true;
break;
case 'U': return true;
break;
default: return false;

}

}

Add a comment
Know the answer?
Add Answer to:
Write a program that write a value-returning function, isVowel, that returns the value true if a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to input a string. The program then uses the...

    Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...

  • Write a C++ Program Write a program that prompts the user to input a number. The...

    Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE

  • Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write...

    Write a C++ Program In C++, struct is a reserved word. Define the struct fruitType. Write a program that declares a variable of type fruitType, prompts the user to input data about a fruit, and outputs the fruit data. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ #include <iostream> #include <string> using namespace std; struct...

  • I'm having trouble to write a value-returning function, isVowel, that returns the value true if a...

    I'm having trouble to write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. Can I get help with this?

  • 4. Write a function that returns a value to the main program illustrated below. In the...

    4. Write a function that returns a value to the main program illustrated below. In the function, the variable passed by the main program needs to be evaluated using a switch statement. The value returned is determined by the case that it matches. (10 points) If value is: return 10 return 20 3 return 30 Anything else, return 0 Main program: #include <iostream> using namespace std; int findValue (int); int main) { Int numb, retvalue cout << "In Enter a...

  • // Write a program that determines how many of each type of vowel are in an...

    // Write a program that determines how many of each type of vowel are in an entered string of 50 characters or less. // The program should prompt the user for a string. // The program should then sequence through the string character by character (till it gets to the NULL character) and count how many of each type of vowel are in the string. // Vowels: a, e, i, o, u. // Output the entered string, how many of...

  • Take the following C++ code and add to it the following: Write a program that reads...

    Take the following C++ code and add to it the following: Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a char variable, and if the character is a vowel, it increments that vowel's count. #include<iostream> #include<string> using namespace std; int countVowel(char, char); int main(void) { string str1; int countA = 0; int countE = 0; int countI...

  • Please help ASAP Question 3 (10 points): Using pointer notation, complete the C++ function below using...

    Please help ASAP Question 3 (10 points): Using pointer notation, complete the C++ function below using pointcr notations The function takes N characters in character array A and return true if the characters are consecutive and fahe otherwise. bool consecutiveChars(char A, int N) char first; // Pointer to the first character in A char last; // Pointer to the last character in A Your code here.. #include <iostream> #include <cctype> using namespace std; bool consecutiveChars(char* A, int N): nt main0...

  • #include <iostream> #include <stack> #include <queue> using namespace std; void printFromStack(string expr){ stack<char> myStack; for(int i=0;...

    #include <iostream> #include <stack> #include <queue> using namespace std; void printFromStack(string expr){ stack<char> myStack; for(int i=0; i<expr.length(); i++){ //Insert code here to push each character onto the stack } cout << "My stack is popped in this order" << endl; while(!myStack.empty()){ //Insert code here to cout the top of the stack one by one //Pop each one after it’s printed out } cout << endl; } void printFromQueue(string expr){ queue<char> myQueue; //Insert code here to push each character onto the...

  • Write a C++ program that will count the number of words and vowels in a sentence....

    Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT