MCQ Single Best Answer Moderate

QWhich statement correctly compares if and switch?

ID: #24861 Control flow in programming 3 views
Question Info
#24861Q ID
ModerateDifficulty
Control flow in programmingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A if is better for exact matches, switch is for ranges
  • B if is better for ranges, switch is for exact matches
  • C Both statements serve the same purpose
  • D switch only works with numbers
Correct Answer: Option B

Explanation

Correct Answer:

(b) if is better for ranges, switch is for exact matches

Explanation:

  • if is useful for conditions like marks > 80
  • switch is useful for exact values like "Monday"

Share This Question

Challenge a friend or share with your study group.