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 c : 1;
    unsigned int n : 2;
    }Stru;
    int ch;
    };
    int main()
    {
    union Un u;
    u.Stru.c = 1;
    printf("%d\n", u.Stru.c);
    }
    1. 0
    2. 1
    3. 2
    4. Garbage value
    5. Compilation Error
Correct Option: B

1



Your comments will be displayed only after manual approval.