Hi Friends, Here I have Written a simple program to count no of vowels in string in c sharp.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FindVowel
{
class Program
{
static void Main(string[] args)
{
int my_count = 0;
Console.WriteLine("Enter String........");
string myString= Console.ReadLine();
foreach(char ch_vowel in myString)
{
switch (ch_vowel)
{
case 'a':
case 'A':
my_count++;
break;
case 'e':
case 'E':
my_count++;
break;
case 'i':
case 'I':
my_count++;
break;
case 'o':
case 'O':
my_count++;
break;
case 'u':
case 'U':
my_count++;
break;
}
}
Console.WriteLine("Number of vowels are :{0}",my_count);
Console.Read();
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.