C++20 sections · 1024 units
Open in Course

The return Statement

Signaling completion

The return 0; statement ends the main function and sends zero to the operating system. Zero means the program finished successfully. Other numbers signal errors. Try changing return 0; to return 1;.

The program still runs and prints output, but the exit code changes. Scripts can check exit codes to see if programs succeeded. Always return 0; when everything works correctly. Non-zero values are for error conditions.