Differentiate break and exit(0) in C++ Programming
1.5 Marks
break:
The "break" statement is used in C++ programming to exit a loop or switch statement. When the "break" statement is encountered, the control is transferred to the next statement after the loop or switch block. It is commonly used to terminate a loop prematurely if a certain condition is met.
exit(0):
The "exit(0)" statement is used in C++ programming to terminate the entire program. When the "exit(0)" statement is encountered, the program is terminated and the control is returned to the operating system. The argument "0" passed to the exit function indicates a successful termination of the program. Other non-zero values can be used to indicate different types of errors or abnormal terminations.