Languages-C & C Plus Plus [TCS Placement]: Sample Questions 43 - 44 of 119

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 43

C & C Plus Plus
Edit

Describe in Detail

Essay▾

How to reduce a final size of executable?

Explanation

To reduce the final size of executable:

  • Remove any dead code
  • Refactor common code to functions where ever possible
  • Use dynamic linking for libraries.

Question 44

C & C Plus Plus

Question

MCQ▾

A union that has no constructor can be initialized with another union of ________ type.

Choices

Choice (4)

a.

Class

b.

Same

c.

Different

d.

Virtual

Answer

b.

Explanation

  • A union is an object that can hold any one of a set of named members. The members of the named set can be of any data type. Members are overlaid in storage.
  • The storage allocated for a union is the storage required for the largest member of the union, plus any padding required for the union to end at a natural boundary of its strictest member.
  • Union member is referenced the same way as referencing a member of a structure.
  • For example:
  1. union {
  2.     charbirthday[9];
  3.     intage;
  4.     floatweight;
  5. } people;
  6. people.birthday[0] ='';
  • Assigns ‘’ to the first element in the character array birthday, a member of the union people.
  • Union data type and a union of that type can be put in the same statement by placing the variable declaration after the data type definition.

Developed by: