Q.1

size of union is size of the longest element in the union

  • Yes
  • No
Q.2

The elements of union are always accessed using & operator

  • Yes
  • No
Q.3

What will be the output of the program ?

#include<stdio.h>

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

    printf("%d, %d, %d\n", bit.bitbit.bitbit.bit4);
    return}
  • 1, 2, 13
  • 1, 4, 4
  • -1, 2, -3
  • -1, -2, -13
Q.4

Bit fields CANNOT be used in union.

  • True
  • False
Q.5

Is it necessary that the size of all elements in a union should be same?

  • Yes
  • No
Q.6

Can we have an array of bit fields?

  • Yes
  • No
Q.7

Will the following code work?

#include<stdio.h>
#include<malloc.h>

struct emp
{
    int len;
    char name[1];
};
int main()
{
    char newname[] = "Rahul";
    struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 +
                    strlen(newname)+1);

    p->len = strlen(newname);
    strcpy(p -> name, newname);
    printf("%d %s\n", p->len, p->name);
    return}
  • Yes
  • No
Q.8

What will be the output of the program inbit platform (Turbo C under DOS) ?

#include<stdio.h>

int main()
{
    struct value
    {
        int bit1:        int bit3:        int bit4:    }bit;
    printf("%d\n", sizeof(bit));
    return}
  • 1
  • 2
  • 4
  • 9
Q.9

one of elements of a structure can be a pointer to the same structure.

  • True
  • False
Q.10

Will the following declaration work?

typedef struct s
{
    int a;
    float b;
}s;
  • Yes
  • No
Q.11

A pointer union CANNOT be created

  • Yes
  • No
Q.12

What will be the output of the program ?

#include<stdio.h>

int main()
{
    enum days {MON=-TUE, WED=THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
    return
}
  • -1, 0, 1, 2, 3, 4
  • -1, 2, 6, 3, 4, 5
  • -1, 0, 6, 2, 3, 4
  • -1, 0, 6, 7, 8, 9
Q.13

A structure can be nested inside another structure.

  • True
  • False
0 h : 0 m : 1 s