Reading Input
Reading numbers and words from standard input with std::cin.
In contest problems the data arrives on standard input: the program reads numbers and strings, processes them and prints the answer. That is exactly how the automatic judge tests you: it feeds test inputs to your program and compares the output with the correct answer.
Reading in C++ is done with std::cin. It skips whitespace and newlines by itself, so it doesn't matter whether the numbers are on one line or several.
Press the "Input" button above the code, enter two numbers separated by a space (for example, 3 5) and run the program.
C++
Enter two numbers in the "Input" field, for example: 3 5
The >> operator reads values one after another: first into a, then into b. You can read any number of values in a row this way.
Words (without spaces) are read into the std::string type — it requires including the string library.
C++
Enter a name and an age, for example: Azat 15
Task: read three numbers and print their arithmetic mean. To get a fractional answer, divide by 3.0 rather than 3.
The main practice is below: solve the problem "Sum of Two Numbers". Open it, write a solution and submit — the judge will check it against the tests. Get the Accepted verdict, then mark the lesson as completed.