Multiple choice general knowledge science & technology

What is the correct value to return to the operating system upon the successful completion of a program in C++

  1. -1

  2. 1

  3. 0

  4. None

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In C++, returning 0 from the main() function signals successful program completion to the operating system. Non-zero values typically indicate errors (with specific values sometimes used to distinguish error types). This convention exists in many programming languages and operating systems, where 0 means "no error" and other values indicate failure conditions.