Python Console I/O: std::cout and std::cin
Programs become genuinely interactive when they can accept input from users. In C++, std::cout prints output using the insertion operator (<<), while std::cin reads user keyboard input into variables using the extraction operator (>>).
"std::cout << is a megaphone projecting sound OUT of your program. std::cin >> is an ear funnel pouring user words INTO a designated variable container."
Deep Dive: How It Works
std::cout << : Inserts data into the standard output stream (the terminal display).
std::cin >> : Extracts characters from the standard input stream (keyboard buffer) into a variable.
Whitespace Delimiter: std::cin >> stops reading at the first space, tab, or newline (so entering "John Doe" only captures "John").
Reading Full Sentences: To read an entire line including spaces, use std::getline(std::cin, myString);.
Syntax Blueprint
int age; std::cout << "Enter age: "; std::cin >> age; // Reads keyboard input into age variable
Prompt user with cout << then capture answer into variable with cin >>.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Reversing the arrows on cin: std::cin << age;Why it happens: Muscle memory from typing std::cout <<.
How to fix: Always use >> with std::cin.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Format a user greeting
Declare std::string name = "Ada"; and int tokens = 25;
Print "User Ada has 25 tokens." to the console.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.