using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
string s1 = "This is test string";
int count = findVowel(s1);
Console.WriteLine( "No of vowels in '" + s1 + "' is : " + count);
}
private static int findVowel(string str)
{
int count = 0;
for (int i = 0; i < str.Length - 1; i++)
{
switch (str[i])
{
case 'a':
count++;
break;
case 'A':
count++;
break;
case 'e':
count++;
break;
case 'E':
count++;
break;
case 'i':
count++;
break;
case 'I':
count++;
break;
case 'o':
count++;
break;
case 'O':
count++;
break;
case 'u':
count++;
break;
case 'U':
count++;
break;
} // end switch
} // end for loop
return count;
}
}
}
Hit Like, if it help full to you... :)
No comments:
Post a Comment