Write a program that prompts the user to input a string. The program then uses t
ID: 3686223 • Letter: W
Question
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 = "Ther", 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 determine whether a character is a vowel. Grading scheme a function to remove all vowels: a function to determ.ne whether a character is vowel: a main function and correct output for any stringExplanation / Answer
#include <iostream>
#include <string>
using namespace std;
bool isvowel(char ch)
{
if(ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U')
{
return true;
}
return false;
}
string substr(string a)
{
int i=0;
while(i<a.length())
{
if(isvowel(a.at(i)))
{
a.erase(i,1);
}
else
{
i++;
}
}
return a;
}
int main() {
// your code goes here
cout<<"Please enter a string:";
string a;
cin>>a;
a=substr(a);
cout<<a<<endl;
return 0;
}