Home » C Programming » Bit Fields » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    union Un
    {
    struct
    {
    unsigned char ch : 2;
    unsigned int n : 2;
    }s;
    int ch;
    };
    int main()
    {
    union Un u = {2};
    printf("%d\n", u.s.ch);
    }
    1. Compilation Error
    2. 0
    3. 2
    4. Nothing
    5. None of these
Correct Option: C

2



Your comments will be displayed only after manual approval.