LOGBOOK

HELP

Quiz Entry - updated: 2026.06.23

How do you write "Hello, world!" in C++?

Include <iostream>, then write cout << "Hello, world!" << endl; inside main().

#include <iostream>
using namespace std;

int main(void) {
    cout << "Hello, world!" << endl;
    return 0;
}

Key C++ elements:

  • #include <iostream> — C++ stream I/O library (not C's stdio.h)
  • using namespace std; — lets you write cout instead of std::cout
  • cout << — sends text to the output stream (the C++ replacement for printf)
  • endl — writes a newline and flushes the buffer (or use "\n" for just the newline)

Compile and run:

$ g++ -o hello hello.cpp
$ ./hello
Hello, world!

From Quiz: REVE1 / C++ Programming | Updated: Jun 23, 2026