Which of the following is the correct value returned to the operating system…

2014

Which of the following is the correct value returned to the operating system upon the successful completion of a program ?

  1. A.

    0

  2. B.

    1

  3. C.

    - 1

  4. D.

    Program do not return a value.

Attempted by 1043 students.

Show answer & explanation

Correct answer: A

Answer: 0 is the correct value returned to the operating system upon successful completion.

Explanation: By convention on Unix-like systems and in many programming languages (for example, C and C++), an exit status of 0 indicates success. The operating system treats 0 as success and any nonzero value as an indication of an error or abnormal termination.

  • Common examples: In C, use return 0; or exit(0); to signal successful completion. In the shell, the special variable $? holds the command exit status, where 0 means success.

  • Nonzero values (for example, 1) indicate errors. Programs may use different nonzero codes to represent different error conditions.

  • Negative values are not a standard success indicator: even if a language accepts an int, the OS typically interprets the exit status modulo 256 (0–255), so a negative value may be converted to a large unsigned value and thus signal failure.

  • If a program does not explicitly return an exit code, the runtime or language standard often provides a default (commonly 0 for successful termination). However, the operating system still receives an exit status.

Therefore, the correct value indicating successful completion is 0.

Explore the full course: Mppsc Assistant Professor