MCQ Practice Single Best Answer Topic: Union in C Language

Q What is the output of this C code?

    #include <stdio.h>
    union
    {
        int x;
        char y;
    }p;
    int main()
    {
        p.y = 60;
        printf("%d\n", sizeof(p));
    }

Question ID
#2690
Subchapter
Union in C Language
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A Compile time error
  • B sizeof(int) + sizeof(char)
  • C Depends on the compiler
  • D sizeof(char)
Correct Answer: C

Explanation

Depends on the compiler

Share This Question

Share this MCQ with your friends or study group.