Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Count vowels in a string

//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            String str = "hello am here now  ooo";
            countVowels(str);
        }
        
        public static void countVowels(String st)
        {
            int vowelct=0;
            
            foreach(char ch in st.ToLower())
            {
                if((ch>='A' && ch<='Z')||(ch>='a' && ch<='z'))
                if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
                    vowelct++;
                 if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
                    vowelct++;             
                
            }
            Console.Write("Vowels count " + vowelct);
            
        }
    }
}
 run  | edit  | history  | help 0