write a program to input a sentence and print the number of characters found in the longest word of the given sentence. for example if S equal " India is my country " then the output should be 7
Answers
Answered by
5
Answer:
public static void Main(string[] args)
{
string input = Console.ReadLine();
string[] splittedwords = input.Split(' ');
int max = 0;
foreach (string word in splittedwords)
{
if (word.Length > max)
{
max = word.Length;
}
}
Console.WriteLine(max);
}
Explanation:
Answered by
0
Answer:
public static void Main(string[] args)
{
All 36%
string input = Console.ReadLine();
string splittedwords = input.Split(' ');
int max = 0;
foreach (string word in splittedwords)
{
if (word.Length > max)
{
max = word.Length;
}
}
Console.WriteLine(max);
Similar questions