text: Program to duplicate Vowels in String | C ++ program for printing string with duplicate vowels ; Function to check for the Vowel ; Function to get the resultant string with vowels duplicated ; Another string to store the resultant string ; Loop to check for each character ; Driver Code ; Print the original string ; Print the resultant string
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; bool isVowel ( char ch ) { ch = toupper ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } string duplicateVowels ( string str ) { int t = str . length ( ) ; string res = " " ; for ( int i = 0 ; i < t ; i ++ ) { if ( isVowel ( str [ i ] ) ) { res += str [ i ] ; } res += str [ i ] ; } return res ; } int main ( ) { string str = " helloworld " ; cout << " Original ▁ String : ▁ " << str << endl ; string res = duplicateVowels ( str ) ; cout << " String ▁ with ▁ Vowels ▁ duplicated : ▁ " << res << endl ; }