QUIZ ON : C LANGUAGE - STRUCTURES AND UNIONS

STRUCTURES AND UNIONS

00:00:00

The size of a structure can be determined by both size of variable name and size of (struct tag).

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

The size of a structure can be determined by both size of variable name and size of (struct tag).

Question No# : 01 out of 19

All the members of a union should be of same type.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

All the members of a union should be of same type.

Question No# : 02 out of 19

Structures can have bit fields.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

Structures can have bit fields.

Question No# : 03 out of 19

A structure can contain similar or dissimilar elements.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

A structure can contain similar or dissimilar elements.

Question No# : 04 out of 19

Which of the data types has the size that is variable?

Option A. int
Option B. struct
Option C. float
Option D. double
True Answer B

Explanation :
Since the size of the structure depends on its fields, it has a variable size.

Which of the data types has the size that is variable?

Question No# : 05 out of 19

All the members of a union share the same memory location.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

All the members of a union share the same memory location.

Question No# : 06 out of 19

A structure can contain pointer to itself.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

A structure can contain pointer to itself.

Question No# : 07 out of 19

What is the similarity between a structure, union and enumeration?

Option A. All of them let you define new values
Option B. All of them let you define new data types
Option C. All of them let you define new pointers
Option D. All of them let you define new structures
True Answer B

Explanation :

What is the similarity between a structure, union and enumeration?

Question No# : 08 out of 19

Difference between structure and union is

Option A. We can define functions within structures but not within a union
Option B. We can define functions within union but not within a structure
Option C. The way memory is allocated
Option D. There is no difference
True Answer C

Explanation :

Difference between structure and union is

Question No# : 09 out of 19

Size of all elements in a union should be same.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Size of all elements in a union should be same.

Question No# : 10 out of 19

typedef is used to give a new name to a known data type.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

typedef is used to give a new name to a known data type.

Question No# : 11 out of 19

What will be the output of the following code?

struct { int si;
double d;
float *cp; } s ;
void main() {
printf(“%d, %d, %d”, sizeof(s.d), sizeof(s.cp), sizeof(s)); }

Option A. 4, 4, 12
Option B. 8, 2, 12
Option C. 10, 4, 16
Option D. 8, 4, 14
True Answer B

Explanation :

What will be the output of the following code?

struct { int si;
double d;
float *cp; } s ;
void main() {
printf(“%d, %d, %d”, sizeof(s.d), sizeof(s.cp), sizeof(s)); }

Question No# : 12 out of 19



In a union, space is allocated to every member individually.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

In a union, space is allocated to every member individually.

Question No# : 13 out of 19

The memory required in structure is less than union.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

The memory required in structure is less than union.

Question No# : 14 out of 19

A structure can contain similar or dissimilar elements

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

A structure can contain similar or dissimilar elements

Question No# : 15 out of 19

enum types are processed by _________

Option A. Compiler
Option B. Preprocessor
Option C. Linker
Option D. Assembler
True Answer A

Explanation :

enum types are processed by _________

Question No# : 16 out of 19

The memory required in structure is less than union.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B

Explanation :

The memory required in structure is less than union.

Question No# : 17 out of 19

Does the data type of all elements in the union will be same?

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

Does the data type of all elements in the union will be same?

Question No# : 18 out of 19

Which of the following is a User-defined data type?

Option A. typedef int Boolean;
Option B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
Option C. struct {char name[10], int age};
Option D. all of the mentioned
True Answer D

Explanation :
typedef and struct are used to define user-defined data types.

Which of the following is a User-defined data type?

Question No# : 19 out of 19