Hello World in C++

From the C++ cheat sheet · Getting Started · verified Jul 2026

Hello World

The entry point and console output.

cpp
// Quick Reference
#include <iostream>

int main() {
    std::cout << "Hello, World!\n";
}
💡 std::cout << chains output; std::cin >> reads whitespace-separated input.
⚡ Prefer "\n" over std::endl in hot loops - endl flushes the buffer every call.
📌 main returns int; a missing return in main implicitly returns 0 (success).
🟢 Qualify with std:: rather than "using namespace std;" to avoid name clashes.
basicsio

More C++ tasks

Back to the full C++ cheat sheet