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*
#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;
}
Comments
Leave a comment