Languages [3i Infotech Placement]: Sample Questions 437 - 438 of 546

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

Question 437

Edit

Describe in Detail

Essay▾

What do you mean by stack unwinding?

Explanation

  • When an exception is thrown, C ++ calls destructors to destroy all the objects formed since the beginning of the try block. The objects are destroyed in the reverse order of their formation. This process is called Stack unwinding.
  • Unwinding during exception handling calls destructor for all local objects between the place where the exception was thrown and where it is caught.
  • Stack unwinding calls all destructors for all automatic objects constructed at run time when an exception is thrown.
Define the Stack Unwinding Structure

Question 438

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. # include <stdio.h>
  2. intaaa () { printf ( “hi” ); }
  3. intbbb () { printf ( “hello” ); }
  4. intccc () { printf ( “bye” ); }
  5. main ()
  6. {
  7.     int ( ⚹ptr[3]) ();
  8.     ptr[0] =aaa;
  9.     ptr[1] =bbb;
  10.     ptr[2] =ccc;
  11.     ptr[2] ();
  12. }

Explanation

In the program

Table Shows the Program
int aaa () {printf ( “hi” ) ;}Define the integer function aaa ()
int bbb () {printf ( “hello” ) ;}Define the integer function bbb ()
int ccc () {printf ( “bye” ) ;}Define the integer function ccc ()
int (⚹ ptr [3] ) () ;int (⚹ ptr [3] ) () says that ptr is an array of pointers to functions that takes no arguments and returns the type int.
ptr [0] = aaa;First function pointer in the array is initialized with the address of the function aaa.
ptr [1] = bbb;Second function pointer in the array is initialized with the address of the function bbb.
ptr [2] = ccc;Third function pointer in the array is initialized with the address of the function ccc.
ptr [2] () ;The call to the function ptr [2] () is same as calling ccc ()

So, it results in printing “bye” .

Developed by: