Examveda

Which of the following cannot be used inside sizeof?

A. pointers

B. functions

C. macro definition

D. none of the mentioned

Answer: Option B

Solution (By Examveda Team)

sizeof is a compile-time operator in C that determines the size, in bytes, of a variable or data type.

Option A: pointers – Valid. sizeof can be used with pointers to determine the size of the pointer type.

Option B: functions – Invalid. You cannot use sizeof on functions because functions do not have a defined size at compile time. sizeof requires a complete type, and functions are not complete objects in C.

Option C: macro definition – Valid. If the macro expands to a valid expression or type, sizeof can be used on it.

Option D: none of the mentioned – Incorrect because functions cannot be used with sizeof.

Therefore, the correct answer is Option B: functions.

This Question Belongs to C Program >> Operators And Expressions

Join The Discussion

Comments (3)

  1. Onkareshwar Datt
    Onkareshwar Datt:
    4 months ago

    ❌ Not allowed directly
    You cannot use sizeof(function_name) because a function doesn't have a size in C.
    However, you can use sizeof(&function_name), because that gives you a function pointer, which does have a size.

    So sizeof(main) is invalid, but sizeof(&main) is valid.

  2. Onkareshwar Datt
    Onkareshwar Datt:
    4 months ago

    ❌ Not allowed directly
    You cannot use sizeof(function_name) because a function doesn't have a size in C.
    However, you can use sizeof(&function_name), because that gives you a function pointer, which does have a size.

    So sizeof(main) is invalid, but sizeof(&main) is valid.

  3. Onkareshwar Datt
    Onkareshwar Datt:
    4 months ago

    The void type means no type—it's an incomplete type, meaning it cannot have a size.

    You cannot apply sizeof to void directly in standard C.

    Doing so will typically result in a compiler error, like:

Related Questions on Operators and Expressions