Thuta Learning
BasicProgrammingbeginner

Syntax & Hello World

Relax. We'll talk through this in plain words — no textbook voice.

A C++ program follows a structure: include headers, decide whether to use a namespace, write your program logic inside the main() function, and close each statement with a semicolon. Once you understand this flow, reading code later becomes a lot easier.

cpp
#include <iostream>
using namespace std;

int main() {
    cout << "Hello World!" << endl;
    cout << "C++ is ready.";
    return 0;
}

using namespace std; is included, so you can write std::cout as just cout. endl starts a new line. main() runs the code inside it in order, from top to bottom.

You should see
Hello World! C++ is ready.

Info

{ } braces mark off a code block. Which block a piece of code is written in matters a lot in C++.

Easy traps

  • Forgetting to close a double quote ", missing a semicolon, or mismatched braces — these all lead to syntax errors.