0

Can someone please help me withe C# Task: Words?

I figure out how to solve the half task. In Test case 2 is the char =" z" the input and i do not know how to make a filter which prints "No match" if the if condition doesn't print anything https://code.sololearn.com/ca86a238a9a7/?ref=app

11th Jun 2021, 9:46 AM
Shiko
Shiko - avatar
3 Answers
+ 2
Someone already asked this and I tried it this way https://code.sololearn.com/cj2j4KC7J7oO/?ref=app
11th Jun 2021, 10:06 AM
Ipang
+ 1
Take a Boolean variable or another int variable as int match=0; Change its value in if block, when matching.. And in out of loop, if value does not change then it means no match. Hope it helps...
11th Jun 2021, 10:08 AM
Jayakrishna 🇼🇳
0
Here is the full task..... using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { string[] words = { "home", "programming", "victory", "C#", "football", "sport", "book", "learn", "dream", "fun" }; string letter = Console.ReadLine(); bool foundmatch =false; int count =0; //your code goes here for(count=0;count <= 9; count++) { if(words[count].Contains(letter)) { Console.WriteLine(words[count]); foundmatch =true; } } if(foundmatch==false) { Console.WriteLine("No match"); } } } }
23rd Aug 2023, 5:59 AM
asad ali shaikh
asad ali shaikh - avatar