ExamVeda
Login
Home
This question belongs to C Program C Fundamentals
C Fundamentals
?

What is the purpose of the 'break' statement in C?

Answer & Solution
Correct Answer: Option D
The purpose of the 'break' statement in C is to exit a loop. When 'break' is encountered within a loop (such as 'for' or 'while' loop), it immediately terminates the loop and continues with the next statement after the loop's body.

So, the correct answer is:

Option D: Exit a loop

Here's an example of using the 'break' statement to exit a loop in C:

for (int i = 1; i <= 10; i++) {
    if (i == 5) {
        break; // Exit the loop when i is equal to 5
    }
    printf("%d ", i);
}
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.