Monday, 30 September 2024

Checking of string contains word contains on another string

 Console.WriteLine("Enter First word: ");

string s1 = Console.ReadLine();

Console.WriteLine("Enter Second word: ");

string s2 = Console.ReadLine();

int j = 0;

for (int i = 0; i < s2.Length; i++)

{

    s1.Contains(s1[i]);

    j++;

}


string s3 = j == s1.Length ? "Word in First word is also present  in the second" : "Word in First word is not present  in the second";


Console.WriteLine(s3);





No comments:

Post a Comment