---
title: 1.1 Printing Hello World
description: "A C++ program begins execution from the `main()` function. Statements inside this function are executed sequentially until the program terminates or returns from `main()`. This example demonstrates the basic structure of a C++ program and uses `std::cout` to display a…"
url: "https://edcret.in/docs/cpp-programming/basic-refreshers-cplusplus/1-1-printing-hello-world/"
updated: "2026-07-28"
category: C++ Programming / Basic Refreshers
---

# 1.1 Printing Hello World

A C++ program begins execution from the `main()` function. Statements inside this function are executed sequentially until the program terminates or returns from `main()`.

This example demonstrates the basic structure of a C++ program and uses `std::cout` to display a message on the standard output stream.

## Source Code

```
#include <iostream>

int main()
{
    std::cout << "Hello, World!\n";

    return 0;
}
```

## Output

```
Hello, World!
```

## Explanation

- `#include <iostream>` includes the standard input/output stream library. It provides objects such as `std::cout`, `std::cin`, `std::cerr`, and `std::clog`.
- `int main()` defines the program entry point. Program execution begins from this function.
- `{ }` defines the body of the `main()` function. All statements belonging to the function are enclosed within these braces.
- `std::cout` is the standard output stream object used to write data to the console.
- The insertion operator (`<<`) sends the string `"Hello, World!"` to the output stream.
- `'\n'` inserts a newline character, causing subsequent output to begin on the next line.
- `return 0;` ends the `main()` function and returns the value `0` to the operating system. A return value of `0` conventionally indicates successful program execution.
