Ch 2 · Your First C++ Program · C++
Topic 2 of 13 in C++ — Complete Tutorial (Beginner) — 2 lessons.
Hello World!
Every C++ program starts in main. To print, we use cout (pronounced "see-out"), which comes from the <iostream> library we include at the top. You send text to cout with the << operator, and endl (or "\n") ends the line. The line using namespace std; lets us write cout instead of std::cout — a convenience for beginners.
cout and Chaining
The real elegance of cout is chaining: you can stream many values in a row with multiple << operators, mixing text, numbers, and variables freely. Each << passes the next item to the output. Unlike C's printf, you do not need format specifiers — cout figures out each value's type automatically.