Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 282 - 284 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 282

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is placement new?

Explanation

  • Placement new is used to call constructor directly.
  • To initialize raw memory that՚s already been allocated
  • Operator new՚s special version placement new allows this. class Widget {public: Widget (int widgetsize) ; … Widget ⚹ Construct_widget_int_buffer (void ⚹ buffer, int widgetsize) {return new (buffer) Widget (widgetsize) ;} } ;
  • This function returns a pointer to a Widget object that՚s constructed within the buffer passed to the function.
  • Such a function might be useful for applications using shared memory or memory-mapped I/O, because objects in such applications must be placed at specific addresses or in memory allocated by special routines.

Question 283

C & C Plus Plus
Edit

Write in Short

Short Answer▾

To which numbering system can the binary number 1101100100111100 be easily converted to?

Explanation

  • This is a 16 bit number.
  • We can group these bits into 4 bits a group.

    (1101) (1001) (0011) (1100)

  • Given set of bits can converted to HEXA DECIMAL SYSTEM
  • (D93C)

Question 284

C & C Plus Plus
Edit

Write in Short

Short Answer▾
  1. voidmain ()
  2. {
  3.     inti =7;
  4.     printf ( “%d”, i ++ ⚹i ++ );
  5. }

Explanation

  • In the program
Table Showing the Program
int i = 7;
  • Define the integer variable i = 7
printf ( “% d” , i ++ ⚹ i ++) ;
  • Solve the equation to print the value
  • = i ++ ⚹ i ++
  • Here (i ++) makes the second value 7 + 1 = 8
  • So 7 ⚹ 8 = 56

Developed by: