C++20 sections · 1024 units
Open in Course

Your First Program

Complete working example

Type this program exactly as shown:

#include <iostream>
using namespace std;
int main() {
    cout << "Hello, World!" << endl;
    return 0;
}

Click run. You should see "Hello, World!" in the output panel. This program has six lines. Each line serves a specific purpose.

If you delete any line except the blank one, the program stops working. Over the next units, I will explain what each line does. Congratulations.

You just wrote and executed your first C++ program. Every C++ program you write will have this same basic structure. Now let us break down each part.