Write a program that counts how many words are in the text entered from the keyboard.

C # language

Console.WriteLine (“Enter text:”); // text output to the console
String str = Console.ReadLine (); // get the text from the console, and save it to a variable
int count = 0; // variable counter
for (int i = 0; i <str.Length; i ++) // loop
{
if (str [i] == ”) // check each character of the text for a space
{
count ++; // if the character is equal to a space, increment the counter
}
}
count ++;
Console.WriteLine (“Number of words:” + count); // print
Console.ReadLine ();



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.