text: Transform the string | CPP code to transform string ; Function to change character 's case ; If character is lowercase change to uppercase ; If character is uppercase change to lowercase ; Function to delete vowels ; If character is consonant ; Function to insert " # " ; If character is not special ; Function to transform string ; Driver function ; Calling function
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; string change_case ( string a ) { int l = a . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( a [ i ] >= ' a ' && a [ i ] <= ' z ' ) a [ i ] = ( char ) ( 65 + ( int ) ( a [ i ] - ' a ' ) ) ; else if ( a [ i ] >= ' A ' && a [ i ] <= ' Z ' ) a [ i ] = ( char ) ( 97 + ( int ) ( a [ i ] - ' A ' ) ) ; } return a ; } string delete_vowels ( string a ) { string temp = " " ; int l = a . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( a [ i ] != ' a ' && a [ i ] != ' e ' && a [ i ] != ' i ' && a [ i ] != ' o ' && a [ i ] != ' u ' && a [ i ] != ' A ' && a [ i ] != ' E ' && a [ i ] != ' O ' && a [ i ] != ' U ' && a [ i ] != ' I ' ) temp += a [ i ] ; } return temp ; } string insert_hash ( string a ) { string temp = " " ; int l = a . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( ( a [ i ] >= ' a ' && a [ i ] <= ' z ' ) || ( a [ i ] >= ' A ' && a [ i ] <= ' Z ' ) ) temp = temp + ' # ' + a [ i ] ; else temp = temp + a [ i ] ; } return temp ; } void transformSting ( string a ) { string b = delete_vowels ( a ) ; string c = change_case ( b ) ; string d = insert_hash ( c ) ; cout << d ; } int main ( ) { string a = " SunshinE ! ! " ; transformSting ( a ) ; return 0 ; }