Unions


  1. What will be the output of the following C code?
    #include <stdio.h>
    union U
    {
    int m;
    char s;
    };
    int main()
    {
    union U u, uu;
    u.m = 65;
    uu.s = 32;
    printf("%d\n", u.s);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    65


  1. What will be the output of the following C code?
    #include <stdio.h>
    union
    {
    int n;
    char ch;
    }U;
    int main()
    {
    U.ch = 201;
    printf("%d\n", sizeof(U));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    sizeof(char)



  1. What will be the output of the following C code?
    #include <stdio.h>
    union
    {
    int n;
    char ch;
    }U;
    int main()
    {
    U.n = 10;
    printf("%d\n", sizeof(U));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    sizeof(int)


  1. What will be the output of the following C code?
    #include <stdio.h>
    union Employee
    {
    int N;
    float F;
    };
    void main()
    {
    union Employee emp;
    emp.N = 26;
    printf("%d", emp.N);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    26



  1. What will be the output of the following C code (Assuming size of int and float is 4)?
    #include <stdio.h>
    union
    {
    int Nval;
    float Fval;
    } U;
    void main()
    {
    printf("%d", sizeof(U));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    4