Skip to content

Commit 2e82ea8

Browse files
authored
Merge pull request #2 from Jahnavi998/Jahnavi998-patch-2
Create CountVowels.cs
2 parents 6432a32 + ba3f02f commit 2e82ea8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Algorithms/Strings/CountVowels.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
namespace Algorithms.Strings;
3+
4+
public static class Vowels {
5+
// comment
6+
// In main method we are reading the input and calling CountVowels method to count the vowels of a given string
7+
// comment
8+
public static void Main(string[] args) {
9+
string input= Console.ReadLine();
10+
CountVowels(input.Trim());
11+
}
12+
// comment
13+
// In CountVowels Method we are printing the count of vowels in given string
14+
// comment
15+
public static void CountVowels(string input)
16+
{
17+
string vowels = "aeiouAEIOU";
18+
int count=0;
19+
for(int i=0;i<input.Length;i++)
20+
{
21+
for(int j=0;j<vowels.Length;j++)
22+
{
23+
if(input[i]==vowels[j])
24+
{
25+
count+=1;
26+
break;
27+
}
28+
}
29+
}
30+
Console.WriteLine($"No of Vowels in a given string is {count}");
31+
}
32+
}

0 commit comments

Comments
 (0)