Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ArrayAlphabet
- {
- static void Main()
- {
- char[] alphabet = new char[27]; //creates the array
- int initializizationOfArray=65; //'A' has value of 65.
- //fills the array
- for (int i = 1; i < 27; i++)
- {
- alphabet[i] = (char) initializizationOfArray;
- initializizationOfArray++;
- }
- Console.WriteLine("Please enter a word with capital letters:");
- string enteredWord = Console.ReadLine().ToUpper();
- //print the index of each of the letters of the word
- foreach (char letter in enteredWord)
- {
- for (int i = 1; i < 27; i++)
- {
- if (alphabet[i]==letter)
- {
- Console.WriteLine("The index of the letter {0} is {1}", letter,i);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement