Answer to Question #271025 in C++ for Kha

Question #271025

Write a program that prompts the user to input as string, then replace each vowel the exists on that string with the


character '*'. You must use character array in implementing your solution.


Sample Run:

Enter a string: 'A' is for "Apple", 'a' - 'a' ... "apple".

'*' *s f*r "*ppl*", '*' - '*' ... "*ppl*


1
Expert's answer
2021-11-24T13:47:57-0500
#include <iostream>

using namespace std;

int main()
{
    string s;
    cout << "Enter a string: ";
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
        char let = tolower(s[i]);
        if (let == 'a' || let == 'e'|| let == 'i'
            || let == 'o' || let == 'u' || let == 'y')
            s[i] = '*';
    }
    cout << s;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS