text: Modify string by removing vowels in between two consonants | C # program to remove all Vowels in between two consonants from the string ; Function to check if the character x is a vowel or not ; Returns the updated string formed after removing all the Sandwiched Vowels from the given string ; string to store the Updated String after removing the Sandwiched Vowels ; traverse the string from left to right ; if the current character is the first or the last character of the string then , this needs to be appended to the updatedString , since the corner alphabet irrespective of it being a vowel or a consonant , is never ' Sandwiched ' ; Check if the current character of the string is a vowel and both the previous and the next characters are consonants , if so then this is a sandwiched vowel , thus is ignored and not appended to the updated string ; if this character is not a sandwiched Vowel append it to the updated String ; Driver Code ; Remove all the Sandwitched Vowels
code: using System ; class GFG { static bool isVowel ( char x ) { if ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) return true ; else return false ; } static String updateSandwichedVowels ( String a ) { int n = a . Length ; String updatedString = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 i == n - 1 ) { updatedString += a [ i ] ; continue ; } if ( ( isVowel ( a [ i ] ) ) == true && isVowel ( a [ i - 1 ] ) == false && isVowel ( a [ i + 1 ] ) == false ) { continue ; } updatedString += a [ i ] ; } return updatedString ; } public static void Main ( ) { String str = " geeksforgeeks " ; String updatedString = updateSandwichedVowels ( str ) ; Console . WriteLine ( updatedString ) ; }