What is the function of the break
statement in C?
a) To exit a loop or switch statement
b) To pause a program
c) To repeat code
d) To declare a variable
Answer:
a) To exit a loop or switch statement
Explanation:
The break
statement in C is used to exit a loop or a switch
statement prematurely, i.e., before the loop has finished its natural course. When the break
statement is encountered, control is immediately transferred to the code following the loop or switch block.
This is useful for stopping loops based on a certain condition or breaking out of a switch
case once a matching case has been executed, improving control over the program’s flow.