0
0
C++programming~5 mins

Input and output using cin and cout in C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is cin used for in C++?

cin is used to take input from the user through the keyboard.

Click to reveal answer
beginner
What does cout do in C++?

cout is used to display output on the screen.

Click to reveal answer
beginner
How do you include the library needed for cin and cout?

You include the <iostream> library at the top of your program using #include <iostream>.

Click to reveal answer
beginner
What symbol is used with cout to send output?

The insertion operator << is used to send output to cout.

Click to reveal answer
beginner
How do you read an integer value from the user using cin?

Declare an integer variable, then use cin >> variableName; to read the value.

Click to reveal answer
Which header file must be included to use cin and cout?
A#include &lt;vector&gt;
B#include &lt;stdio.h&gt;
C#include &lt;string&gt;
D#include &lt;iostream&gt;
What operator is used to get input from the user with cin?
A&lt;&lt;
B&gt;&gt;
C+=
D==
How do you print the text "Hello" using cout?
Acout &lt;&lt; "Hello";
Bcout &gt;&gt; "Hello";
Ccin &lt;&lt; "Hello";
Dprint("Hello");
What will this code do?<br>
int x; cin >> x;
ARead a value from the user and store it in x
BCause a syntax error
CDeclare x as a string
DPrint the value of x
Which of these is the correct way to output multiple items?<br>
cout << "Age: " << age << endl;
AWrong, use plus signs instead
BWrong, use commas instead
CCorrect
DWrong, use semicolons instead
Explain how to take an integer input from the user and then print it using cin and cout.
Think about the steps from declaring a variable to showing it on screen.
You got /4 concepts.
    Describe the role of the operators >> and << in C++ input and output.
    Focus on what each operator does with cin and cout.
    You got /3 concepts.