© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

5.  What do you mean by Stack unwinding?

Ans:
It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.

Ex - 1: What is the output?

main()
{
            int i=10;
            void pascal f(int,int,int);
f(i++,i++,i++);
            printf(" %d",i);
}
void pascal f(integer :i,integer:j,integer :k)
{
write(i,j,k);
}

Ans:
Compiler error:  unknown type integer
Compiler error:  undeclared function write

Explanation:

Pascal keyword doesn’t mean that pascal code can be used. It means that the function follows Pascal argument passing mechanism in calling the functions.

Ex - 2: What is the output?.

int swap(int *a,int *b)
{
 *a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
                        int x=10,y=20;
            swap(&x,&y);
                        printf("x= %d y = %d\n",x,y);
}

Ans:
            x = 20 y = 10

Explanation:
This is one way of swapping two values. Simple checking will help understand this.


SLogix Student Projects
bottom