---
title: "Break and default in switch"
subject: "Computer Programming"
chapter: 5
key: "semester_1/computer_programming:break-default-switch"
source: https://www.bctengineer.com/q/semester_1/computer_programming/break-default-switch
site: BCT Engineering
---

# Break and default in switch

Computer Programming · Chapter 5: Control statements

- Asked in: 2070 Chaitra, 3 marks
- Video: [#11: Switch Statement in C | [2025] C Programming for Beginners](https://www.youtube.com/watch?v=u6mb8NNwojA) — Programiz
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/break-default-switch
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-5

## Question

Explain importance of break and default statements in switch statements.

## Answer

- **`break`:** ends the switch after a case is executed, so control leaves the switch. Without it, execution **falls through** into the next cases, running them too, even though their values do not match.
- **`default`:** the block executed when none of the case values matches the expression. It handles invalid or unexpected values, and acts like the final `else`. It is optional, and is usually written last.

```c
#include <stdio.h>
int main(void)
{
    int n = 2;
    printf("Without break:\n");
    switch (n)
    {
        case 1: printf("One\n");
        case 2: printf("Two\n");
        case 3: printf("Three\n");
        default: printf("Default\n");
    }
    printf("With break and default:\n");
    switch (n + 5)
    {
        case 1: printf("One\n");   break;
        case 2: printf("Two\n");   break;
        default: printf("No match\n");
    }
    return 0;
}
```
Output:
```text
Without break:
Two
Three
Default
With break and default:
No match
```

In the first switch (n = 2) there is no `break`, so "Two", "Three" and "Default" are all printed. In the second, no case matches 7, so `default` prints "No match".

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What happens in a switch case without break?
   A. Execution continues into the following cases
   B. Control returns to the top of the switch
   C. The compiler gives an error
   D. Only default is executed
   Answer: A. Missing break causes fall-through into the next cases even if they do not match. (Key point: Fall through)

2. n = 2 and no break statements, cases 1, 2, 3 and default. What is printed?
   A. Two only
   B. Two, Three, Default
   C. One, Two, Three, Default
   D. Three, Default
   Answer: B. Matching starts at case 2 and falls through all later blocks. (Key point: Trace without break)

3. What is default similar to in an if-else ladder?
   A. The first if
   B. A nested if
   C. The final else
   D. The condition
   Answer: C. default runs when no case matches, like the last else. (Key point: Default meaning)

4. In the second switch (n+5 = 7 with break and default), what is printed?
   A. Two
   B. One
   C. Nothing
   D. No match
   Answer: D. 7 matches no case, so default prints No match. (Key point: Switch with n+5)

## Related in other subjects

- [Break-even units and output for desired profit](https://www.bctengineer.com/question.md?key=semester_6%2Fengineering_economics%3Abreakeven-units-profit-50000) — Engineering Economics, chapter 1
