Skip to content
Sign in
Assistant Director (BS-17) Held in 12.07.2025 PPSC

In C++, the library function exit() causes?

Tap an option to check the answer. You can also press A–D.

Show answer

Correct answer: A) Exit from the program

In C++, the exit() library function (from cstdlib) terminates the entire program immediately. To leave only a loop, programmers use break or continue instead. Related facts: exit() closes all streams and terminates the process; return only exits the current function.exit(0) indicates normal termination; exit(1) indicates an error. Exam tip: This is a commonly tested basic fact in computer science. Distinguish exit() (whole program) from break (loop) and return (function).
Explanation
In C++, the exit() library function (from cstdlib) terminates the entire program immediately. To leave only a loop, programmers use break or continue instead. Related facts: exit() closes all streams and terminates the process; return only exits the current function.exit(0) indicates normal termination; exit(1) indicates an error. Exam tip: This is a commonly tested basic fact in computer science. Distinguish exit() (whole program) from break (loop) and return (function).