Taking User Input
Learn how we can take input from users in C++.
We'll cover the following...
We'll cover the following...
In the previous chapter, we learned how the cout
statement displays output to the console, but we did not discuss how it takes input in C++. In this lesson, we’ll explore how C++ uses its operators to take input from the user.
C++ input
C++ uses the statement cin
and operator >>
to get user input and store it in a memory location in C++. The basic syntax of how cin
takes input is:
<cin> >> <variable_name> <;>
...