Area of Improvements

Review your assessments and practice — drill into each subject, then each attempt, then each question.

Back to summary
C Programming · Round 1

Question 3 of 10

Topic: Keywords & identifiersDifficulty: MediumBloom: Analyze
Question

Compare control structures (if/else vs switch) in C and discuss trade-offs.

Result
Knowledge
75%
Delivery
70%
Technical relevancy
80%
Technical term match
72%
Your recording
Your transcript

Switch is faster than if-else I think, because the compiler makes a jump table. If-else is more flexible because you can do ranges and stuff. You always need break in switch otherwise it falls through.

Better answer

if/else handles arbitrary boolean expressions including ranges and compound conditions; switch dispatches on a single integer/char value and is often compiled to a jump table for O(1) dispatch on dense cases. Switch requires break to prevent fallthrough (intentional fallthrough is a common bug source). Prefer switch for many discrete equality checks on the same variable, if/else for ranges or complex predicates.

Coverage
Hit 3 of 5
  • Notes switch dispatches on integral/char only
  • Mentions jump-table optimisation for switch
  • Calls out fallthrough behaviour and break
  • Recommends if/else for ranges or complex predicates
  • Discusses readability/maintenance trade-off
Gaps
  • Did not give a concrete rule for when to choose each
Misconceptions
  • Said switch is 'always' faster than if/else