C - Structure and Union Questions and Answers
Practice ModeShowing 10 of 51 questions
Q41
Which of the following will define a type NODE that is a node in a linked list.
Answer: Option C
Q42
The size of the following union, where an int occupies 4 bytes of memory is
union arc
{
char x;
int y;
char ax [8];
} ahs;
Answer: Option C
Q43
union rainbow
{
int a [ 5];
float x [5];
};
union rainbow color [20];
void *ptr = color;
Which of the following is the correct way to increment the variable "ptr" to point to the next member of the array from the sample above /
Answer: Option B
Q44
Which is the valid declaration ?
Answer: Option D
Q45
The following statement is
"The soze of a struct is always equal to the sum of the sizes of its members."
Answer: Option C
Q46
struct adr
{
char *name;
char *city;
int zip;
};
struct adr *adradr;
whioch are valid references?
(i) adr->name
(ii) adradr->name
(iii) adr. zip
(iv) adradr.zip
Answer: Option B
Q47
struct
{
int x;
int y;
}abc;
you cannot access x by the following:
1. abc->x;
2. abc[ 0 ] ->x;
3. abc.x;
4. (abc)->x;
Answer: Option A
Q48
What is the size of 'q' in the following program ?
Assume int takes 4 bytes.
union {
int x;
char y;
struct
{
char x;
char y;
int xy;
}p;
}q;
Answer: Option B
Q49
What is the output of the following code /
union {
int no;
char ch;
} u;
u. ch = '2';
u.no = 0,
printf ("%d", u.ch);
Answer: Option B
Q50
Which of these are valid declarations ?
(i) union (
int i;
int j;
};
(ii) union u-tag {
int i;
int j;
}u;
(iii) union {
int i;
int j;
FILE *k;
};
(iv) union {
int i;
int j;
} U;
Answer: Option C