//Write a program that prompts the user to input a string. Theprogram then uses
ID: 3615492 • Letter: #
Question
//Write a program that prompts the user to input a string. Theprogram then uses the function substr to removeall the vowels from the string. For example, if str ="There", thenafter removing all the vowels, str="Thr". After removing all thevowels, output the string. Your program must contain a functionremove all the vowels and a function to determine whether acharacter is a vowel. (Using Dev C++)
//series of function calls to do each step of the program,
//e.g. getInput(), removeVowels(), outputString(),
//and you will also have your existing functionisVowel().
// Make appropriate use of Value and Reference parameters.
#include <iostream>
#include <string>
using namespace std;
string substr (string str);
bool isVowel (char c);
int main ()
{
string str, str1,;
cout << "Please enterstring:";
cin >> str;
str1 = substr(str);
cout << str1;
system ("PAUSE");
return 0;
}
string substr(string str)
{
int i=0, temp;
bool check;
while (i < str)
{
check =isVowel(str[i]);
if (check)
{
temp = i;
while (i < str)
{
str[i] = str[i + 1];
i++;
}
i=temp;
}
else
i++;
}
return str;
}
bool isVowel (char c)
{
if (c=='a' || c=='e' ||c=='i' || c=='o'||c=='u')
return true;
else
return false;
}
Explanation / Answer
please rate - thanks //series of function calls to do each step of the program, //e.g. getInput(), removeVowels(), outputString(), //and you will also have your existing function isVowel(). // Make appropriate use of Value and Reference parameters. #include #include using namespace std; void substr (string & str); bool isVowel (char c); void removeVowels(string& str,int i); string getInput(); void outputString(string str, string str1); int main () { string str, str1,; str=getInput(); str1=str; //say for later, I think your supposed to remove vowels fromitself substr(str); outputString(str,str1); system ("PAUSE"); return 0; } void outputString(string str, string str1) {coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.