Program to count vowels in a string ( Iterative and Recursive ) | Recursive C # program to count the total number of vowels using recursion ; Function to check the Vowel ; to count total number of vowel from 0 to n ; Main Calling Function ; string object ; Total numbers of Vowel
using System ; public class GFG { public static int isVowel ( char ch ) { ch = char . ToUpper ( ch ) ; if ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) { return 1 ; } else { return 0 ; } } public static int countVowels ( string str , int n ) { if ( n == 1 ) { return isVowel ( str [ n - 1 ] ) ; } return countVowels ( str , n - 1 ) + isVowel ( str [ n - 1 ] ) ; } public static void Main ( string [ ] args ) { string str = " abc ▁ de " ; Console . WriteLine ( countVowels ( str , str . Length ) ) ; } }