cout <<
Try it yourself →Writes to the output stream.
Syntax
cout << value;
Description
You write values to the output with the << operator (you can chain them). endl or "\n" adds a new line. Requires <iostream>.
Example
#include <iostream>
using namespace std;
int main() {
cout << "Hello" << " World" << endl;
cout << 3 + 4 << endl;
return 0;
}Expected output
Hello World 7
When to use?
Showing results, debugging.
Common mistakes
- ⚠️ << direction matters: cout << value (stream to left).