Count of substrings consisting only of vowels | C # program to count all subStrings in a String which contains only vowels ; Function to check if a character is vowel or not ; Function to check whether String contains only vowel ; Check if the character is not vowel then invalid ; Function to Count all subStrings in a String which contains only vowels ; Generate all subString of s ; If temp contains only vowels ; Increment the count ; Driver code
using System ; class GFG { static Boolean isvowel ( char ch ) { return ( ch == ' a ' ch == ' e ' ch == ' i ' ch == ' o ' ch == ' u ' ) ; } static Boolean isvalid ( string s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isvowel ( s [ i ] ) ) return false ; } return true ; } static int CountTotal ( string s ) { int ans = 0 ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { string temp = " " ; for ( int j = i ; j < n ; j ++ ) { temp += s [ j ] ; if ( isvalid ( temp ) ) ans += 1 ; } } return ans ; } public static void Main ( ) { string s = " aeoibsddaaeiouudb " ; Console . Write ( ( CountTotal ( s ) ) + " STRNEWLINE " ) ; } }