DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Count number of vowels in a string using C#.NET

By Ashok Nalam on 10 Dec 2013 | Category: C# | Tagged: string .NET 
Snippet counts number of vowels in a string using C#.NET
  Discuss Add Comment   |  
Add rating Rate this resource   
Below program counts number of vowels in a string using C#.NET

Simple Program:

using System;
namespace DotNetMirror
{
    class CountNumberOfVowels
    {
        static void Main()
        {
            int vowelsCount = 0;
            Console.WriteLine("Please enter string value to count no of vowels in it:");
            string strValue = Console.ReadLine();
            for (int j = 0; j < strValue.Length; j++)
            {
                if (strValue[j] == 'a' || strValue[j] == 'A' || strValue[j] == 'e' || strValue[j] == 'E' || strValue[j] == 'i' || strValue[j] == 'I' || strValue[j] == 'o' || strValue[j] == 'O' || strValue[j] == 'u' || strValue[j] == 'U')
                {
                    vowelsCount++;
                }
            }
            Console.WriteLine("No of vowels in [{0}] are {1}" , strValue, vowelsCount);
            Console.ReadLine();
        }
    }
}

Output:

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9226  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.
 
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys