What is the purpose of the ‘break’ statement in C?

What is the purpose of the ‘break’ statement in C?

a) To terminate a loop or switch statement
b) To skip an iteration of a loop
c) To exit a function
d) To define a block of code

Answer:

a) To terminate a loop or switch statement

Explanation:

The break statement in C is used to terminate the execution of a loop (such as for, while, or do-while) or to exit a switch statement. When a break statement is encountered, the control flow immediately jumps to the statement following the loop or switch, effectively ending the current iteration or case.

Understanding the break statement is important for controlling the flow of loops and switch cases in C programming.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top