0
0
C++programming~5 mins

Using cout for output in C++ - Cheat Sheet & Quick Revision

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

cout is used to display output on the screen, like printing messages or values.

Click to reveal answer
beginner
How do you print the text Hello, World! using cout?

Use std::cout << "Hello, World!" << std::endl; to print the text and move to a new line.

Click to reveal answer
beginner
What does << mean when used with cout?

<< is called the insertion operator. It sends data to cout to be printed.

Click to reveal answer
beginner
How do you print multiple items with cout?

Use << to chain items, like std::cout << "Age: " << age << std::endl;.

Click to reveal answer
beginner
Why do we use std::endl with cout?

std::endl moves the cursor to the next line and flushes the output buffer, ensuring the output appears immediately.

Click to reveal answer
What does cout do in C++?
AStores data in memory
BReads input from the keyboard
CPerforms mathematical calculations
DPrints output to the screen
Which operator is used with cout to display data?
A<<
B==
C++
D>>
How do you print a new line after output using cout?
AUse <code>;</code>
BUse <code>\n</code> inside the string
CUse <code>std::endl</code>
DUse <code>return</code>
What will this code print?<br>std::cout << "Age: " << 25 << std::endl;
AAge: 25
B25 Age:
CAge 25
DError
Which header file must be included to use cout?
A<code>&lt;string&gt;</code>
B<code>&lt;iostream&gt;</code>
C<code>&lt;vector&gt;</code>
D<code>&lt;cmath&gt;</code>
Explain how to use cout to print a message and a number on the same line.
Think about chaining multiple items with <<
You got /5 concepts.
    Describe the role of std::endl when used with cout.
    It helps move to the next line and ensures output shows up right away
    You got /4 concepts.