1. What is this?
A program is instructions the machine executes. In C++, execution starts in a function called main. #include <iostream> loads input/output tools. std::cout << "Hi" sends text to the output; << chains pieces; std::endl ends the line. A string is text in double quotes.
2. Why do we use it?
C++ powers games, browsers, and trading systems where speed matters. Understanding main and output is the doorway.
3. Syntax breakdown
#include <iostream>
Loads the input/output library so cout is available.
int main() {Entry point. Returns an int (0 = success). Braces group the body.
std::cout << "Hello" << std::endl;
Prints Hello and a newline. Statements end with ;.
5. Common mistakes
- Forgetting #include <iostream> — cout is then undefined.
- Missing semicolon after the cout line.
- Forgetting return 0; (works without it in main, but be explicit while learning).
Practice task
Print your name on line 1 and "Learning C++ step by step." on line 2.
Hint
Add a second std::cout line with << std::endl.
Try it below — tests run automatically when you press Run.
Output
Press Run to see output.
Mini quiz
3 questions. Answer, then check.
1. Where does a C++ program start?
2. What does #include <iostream> do?
3. What ends a statement?