LearnFrenzy
Sign in Take a free test

Decision Making · Decision Making MCQ · Question 12

Can a C switch test a range such as 90 to 100? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

Is case 90 ... 100: valid standard C?

  • A Yes, since C99
  • B Yes, since C23
  • C No – case ranges are a GNU extension (proposed for the next standard); use an if-else ladder Correct
  • D Only for char values
Correct Answer: Option C

Standard C, C23 included, allows only single constant case labels. GCC and Clang accept ranges as an extension, and Clang with -pedantic-errors rejects them as "a C2y extension". For ranges, if-else is the portable tool.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links