The task is:
The program you are given defines an array with 10 words and takes a letter as input.
Write a program to iterate through the array and output words containing the taken letter.
If there is no such word, the program should output “no match”.
Sample Input: “u”
Sample Output: ” fun”
Now this is how I wrote this program
static void Main(strings[] args)
{
string[] words={"home","programming","victory","C#","football","sport","book","learn","dream","fun"};
string letter = Console.ReadLine();
//your code goes here
string word = "";
for (int y = 0; y < words.Length; y++)
{
if (words[y].Contains(letter))
{
Console.WriteLine(words[y]);
word += words[y];
}
}
if (word.Length == 0)
{
Console.WriteLine("No match");
}
}