fk4m1913

Untitled

Jun 14th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace VowelsCount
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.             char[] vowels = { 'a', 'o', 'u', 'e', 'i', 'A', 'O', 'U', 'E', 'I' };
  12.  
  13.             Console.WriteLine(CountVowels(input, vowels));
  14.         }
  15.  
  16.         static int CountVowels(string input, char[] vowels)
  17.         {
  18.             int vowelsCount = 0;
  19.  
  20.             for (int i = 0; i < input.Length; i++)
  21.             {
  22.                 if (vowels.Contains(input[i]))
  23.                 {
  24.                     vowelsCount++;
  25.                 }
  26.             }
  27.  
  28.             return vowelsCount;
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment