Thursday, 2 May 2013

How to make vowel get program in c#

How to make vowel get program in c#

Object



Write a program in C# that prompts the user to provide five characters and store them in an array. Pass the array to a function called countVowels() that finds and returns the number of vowels present in the array. Consider both capital and small letters.

Code

class wovel
    {
        char count;
        public static char wov(char[] arr)
        {
            for (int j = 0; j < 5; j++)
            {

                if (arr[j] == 'a' || arr[j] == 'A' || arr[j] == 'e' || arr[j] == 'E' || arr[j] == 'i' || arr[j] == 'I' || arr[j] == 'O' || arr[j] == 'o' || arr[j] == 'u' || arr[j] == 'U')
                {

                    count++;


                }
            }
            return count;

        }



int i = 0;
        int total=0;
      
        char[] arr = new char[5];
       
        for (; i < 5; i++)
        {
            Console.Write("Enter The Character :: ");
            arr[i] = char.Parse(Console.ReadLine());
        }
        Console.WriteLine("\n\n");
       
       total= program.wov(arr);

            Console.WriteLine("Total wovel Is ::"+ total);
            Console.WriteLine("\n\n");
        }
        }
    }
}

Screen Shot
 


No comments:

Post a Comment