Union in C Exercise I


Ques 1 Union


Which of the following is a keyword of union ?
  a) Union
  b) UNION
  c) union()
  d) None of the above


d is the correct option




Ques 2 Union


What is the size of Union?
union student
{
    char name[12];
    int roll[5];
    float percentage;
}

  a) 12
  b) 18
  c) 26
  d) 28


a is the correct option




Ques 3 Union


What is the output of the code ?
union things{
int a;
float b;
char c;
};
int main()
{
union things d;
d.a=45;
d.b=3.5;
d.c="Grocery";
printf("%d\n",d.a);
printf("%f\n",d.b);
printf("%c\n",d.c);
return 0;
}

  a) 45 3.50000 grocery
  b) 35 3.5 Grocery
  c) 45 3.50000 Gocery
  d) None of these


c is the correct option