Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Write a program that creates an array containing all letters from the alphabet (A-Z).
- //Read a word from the console and print the index of each of its letters in the array.
- using System;
- class IndexOfEachLetter
- {
- static void Main()
- {
- char[] alphabet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
- string word = Console.ReadLine();
- foreach (char letter in word)
- {
- for (int index = 0; index < alphabet.Length; index++)
- {
- if (letter == alphabet[index])
- {
- Console.WriteLine("letter {0} is with index {1}", letter, index);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement