Count vowels in one words

Satyapriyanayak
Posted by Satyapriyanayak under C# category on | Points: 40 | Views : 1037
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter a word : ");
string word = Console.ReadLine();
Console.WriteLine("There are {0} vowels in {1}", CountVowels(word), word);
Console.ReadKey();
}
static int CountVowels(string word)
{
word = word.ToLower();
int count = 0;
foreach (char c in word)
{
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') count++;
}
return count;
}
}
}

Comments or Responses

Login to post response