Replace all consonants with nearest vowels in a string | C ++ program to replace all consonants with nearest vowels in a string ; Function to replace consonant with nearest vowels ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string replacingConsonants ( string s ) { char nVowel [ ] = " aaaeeeeiiiiioooooouuuuuuuu " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) s [ i ] = nVowel [ s [ i ] - ' a ' ] ; return s ; } int main ( ) { string s = " geeksforgeeks " ; cout << replacingConsonants ( s ) ; return 0 ; }