Hello, World

A main function, #include <iostream> and std::cout.

Runs in Zerethon IDE · C++ (GCC 14) Official C++ documentation ↗
main.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!\n";
    std::cout << "Sum: " << 2 + 3 << '\n';
    return 0;
}

Output

Hello, World!
Sum: 5
  • << sends values to the stream one after another; \n ends the line (std::endl also flushes, which is slower).
  • Standard names live in the std namespace: std::cout, std::string, std::vector.
  • return 0; from main means success (it may be left out in main only).