Difference between revisions of "Testing if a character is in a word"
(Created page with " Console.WriteLine("please enter a word:"); string word = Console.ReadLine(); string vowels = "aeiou"; foreach(char c in word) { if(vowels.Contains(c.ToString()...") |
|||
Line 1: | Line 1: | ||
− | + | <syntaxhighlight lang=csharp line> | |
− | + | Console.WriteLine("please enter a word:"); | |
− | + | string word = Console.ReadLine(); | |
+ | string vowels = "aeiou"; | ||
− | + | foreach(char c in word) | |
− | + | { | |
− | + | if(vowels.Contains(c.ToString())) | |
− | + | { | |
− | + | Console.WriteLine("Vowel found: "+c); | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | Console.ReadLine(); | |
+ | </syntaxhighlight> |
Revision as of 11:41, 15 June 2023
1 Console.WriteLine("please enter a word:");
2 string word = Console.ReadLine();
3 string vowels = "aeiou";
4
5 foreach(char c in word)
6 {
7 if(vowels.Contains(c.ToString()))
8 {
9 Console.WriteLine("Vowel found: "+c);
10 }
11 }
12
13 Console.ReadLine();