Examveda

What will be the output of the following C code?
#include <stdio.h>
union u
{
    struct
    {
        unsigned char x : 2;
        unsigned int y : 2;
    }p;
    int x;
};
int main()
{
    union u u.p = {2};
    printf("%d\n", u.p.x);
}

A. Compile time error

B. 2

C. Undefined behaviour

D. None of the mentioned

Answer: Option A


This Question Belongs to C Program >> Structure And Union

Join The Discussion

Related Questions on Structure and Union