c++
1. Write a program that takes in a string as an input of any size and replaces all vowel letters in the
string with an ‘x’. You must use Logical Operators and implement it using a user-defined function.
#include <iostream> using namespace std; string replaceVowels(string input){ for(int i = 0;input[i]!='\0';i++){ if(input[i] == 'A' || input[i] == 'E' || input[i] == 'I' || input[i] == 'O' || input[i] == 'U' || input[i] == 'a' ||input[i] == 'e' ||input[i] == 'i' ||input[i] == 'o' ||input[i] == 'u'){ input[i] = 'x'; } } return input; } int main(){ string s; cout<<"Enter string: "; cin>>s; s = replaceVowels(s); cout<<s<<endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.