Home » C Programming » Bit Fields » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Stru
    {
    unsigned int ch : 2;
    unsigned int n : 2;
    };
    int main()
    {
    struct Stru s;
    s.ch = 3;
    s.n = 1;
    printf("%d\n", sizeof(s));
    }
    1. 2
    2. 4
    3. Undefined behaviour
    4. Garbage value
    5. None of these
Correct Option: B

4



Your comments will be displayed only after manual approval.