GoConqr has a new look! Let us know what you think.

Quiz

C data types: unions, bit fields and enums

saisuhruth 5 questions

Take the quiz

This quiz has a time limit, so it opens in the usual player.

Questions in this quiz (5)

  1. 1What will be the output of the program ?
    #include<stdio.h>

    int main()
    {
    union var
    {
    int a, b;
    };
    union var v;
    v.a=10;
    v.b=20;
    printf("%d\n", v.a);
    return 0;
    }
    1. A10
    2. B20
    3. C30
    4. D0
  2. 2What will be the output of the program ?
    #include<stdio.h>

    int main()
    {
    struct value
    {
    int bit1:1;
    int bit3:4;
    int bit4:4;
    }bit={1, 2, 13};

    printf("%d, %d, %d\n", bit.bit1, bit.bit3, bit.bit4);
    return 0;
    }
    1. A-1, 2, -3
    2. B1, 2, 3
    3. C1, 4, 4
    4. D-1, -2, -13
  3. 3What will be the output of the program in 16 bit platform (Turbo C under DOS) ?
    #include<stdio.h>

    int main()
    {
    struct value
    {
    int bit1:1;
    int bit3:4;
    int bit4:4;
    }bit;
    printf("%d\n", sizeof(bit));
    return 0;
    }
    1. A1
    2. B2
    3. C4
    4. D9
  4. 4What will be the output of the program ?
    #include<stdio.h>

    int main()
    {
    enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
    return 0;
    }
    1. A-1, 0, 6, 7, 8, 9
    2. B-1, 0, 1, 2, 3, 4
    3. C-1, 2, 6, 3, 4, 5
    4. D-1, 0, 6, 2, 3, 4
  5. 5What will be the output of the program ?
    #include<stdio.h>

    int main()
    {
    enum status {pass, fail, absent};
    enum status stud1, stud2, stud3;
    stud1 = pass;
    stud2 = absent;
    stud3 = fail;
    printf("%d %d %d\n", stud1, stud2, stud3);
    return 0;
    }
    1. A0, 2, 1
    2. B0, 1, 2
    3. C1, 2, 3
    4. D1, 3, 2

Information

Description
Quiz on Untitled, created by saisuhruth on 26/01/2016.
Language
English
Views
0
Rating
No ratings yet
Rate this quiz
Rate this quiz

More on Data Types, Variables and Operators

Feedback

What is it about?

What do you think of the new look?

How do you like it?