how to remove the vowels from the user input.?
remove vowels from user input string
Collapse
X
-
Code:#include<iostream> #include<string> #include<sstream> using namespace std; int main() { char word[1000]; char b[6]={'a','e','i','o','u'}; cout<<"enter the word:\t"; cin>>word; for(int i=0;i<=1000;i++) { char d=word[i]; if(d==b[0]) { } else if(d==b[1]) { } else if(d==b[2]) { } else if(d==b[3]) { } else if(d==b[4]) { } else cout<<"\r \n"<<d; } } -
try this and suggest ideas
Code:#include<iostream> #include<string> #include<sstream> using namespace std; int main() { char word[1000]; char b[6]={'a','e','i','o','u'}; cout<<"enter the word:\t"; cin>>word; for(int i=0;i<=1000;i++) { char d=word[i]; if(d==b[0]) { } else if(d==b[1]) { } else if(d==b[2]) { } else if(d==b[3]) { } else if(d==b[4]) { } else cout<<"\r \n"<<d; } }Comment
-
The easiest thing to do is to make a copy of your input string. You would write a loop copy from your input a character at a time. Test each character to be a vowel and if it is don't copy it.
Your copy will have no vowels.
Finally, copy back to the original input.Comment
Comment