LearnFrenzy
Sign in Take a free test

C Const · const MCQ · Question 12

Where can a C23 constexpr object be used? Answer, explanation & discussion

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

In C23, which use is valid for constexpr int N = 8; that is not valid for const int N = 8;?

  • A Reading N in printf
  • B Using N as a case label or a global array size Correct
  • C Taking its address
  • D Passing it to a function
Correct Answer: Option B

A constexpr object is an integer constant expression, so it can appear wherever C requires one – case labels, static array sizes, bit-field widths. A plain const int cannot.

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