Javatpoint Logo
Javatpoint Logo

C Structure, Union, Enums Test 4


16) Find out the error in the below program?

  1. Error: in structure declaration
  2. Linker
  3. No error
  4. None of the above

The correct option is (c).

Explanation:

This type of declaration is known as self-referential structure. This type of declaration is allowed to be used in a program.

Here *e is the pointer to a struct employ.

Therefore the compiler will return No error in a program


17) The Bit fields cannot be used in a union.

  1. True
  2. False

The correct option is (b).

Explanation:

False, the bit fields are allowed to be used inside a union.

The C program using bit fields inside a union is given below:


18) The union elements can be of different sizes.

  1. True
  2. False

The correct option is (a).

Explanation:

True, the union element can be of different sizes.

All the union elements may have different sizes but they share the common space of memory.


19) If the below structure is used for writing into a file using fwrite(), can fread() read it back successfully?

  1. Yes
  2. No

The correct option is (b).

Explanation:

No, because the structure in a program contain a char pointer while writing the structure to the disk using fwrite() only the data stored in pointer 'n' will get written. Hence the fread() fails to read the data stored in pointer.

Therefore the fread() cannot read it back successfully.


20) What will be the output of a program in Turbo C under DOS (16 bit platform)?

  1. 9
  2. 4
  3. 2
  4. 1

The correct option is (c).

Explanation:

Since the C language is machine or compiler dependent language. In Turbo C(DOS) the size of integer data type is 2.

Therefore the statement printf("%d \n", sizeof(bit)); prints the value 2 in output.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA