LearnFrenzy
Sign in Take a free test

Operators and Expressions · Operators MCQ · Question 7

Is sizeof a function or an operator? Answer, explanation & discussion

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

Which statement about sizeof is true?

  • A It is a library function from <stdlib.h>
  • B It is an operator, usually evaluated at compile time; its operand is not executed (except for VLAs) Correct
  • C It always needs brackets
  • D It returns an int
Correct Answer: Option B

sizeof x needs no brackets for an expression (only for a type name, sizeof(int)). Its result is a size_t, and an operand such as i++ is never evaluated.

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