The above program uses the concept of function pointer.P[0] & P[1] are nothing but function pointer.
When we say P[0](&a,b) , P[1](&a,b).It is same as f1(&a,b) ,f2(&a,b) respectively.
In this program the function f1(),f2() are using the concept called call by reference and call by value.The first parameter to both the functions is call by reference and second parameter is call by value.
So in functions f1() and f2(),we are trying to swap the contents.But we are passing address of the variable a only.So,changes made in the calling function will be reflected to the called function.But it won't happen with b,as it is call by value.
Ans:5 5 5 5
ReplyDeleteExp:
The above program uses the concept of function pointer.P[0] & P[1] are nothing but function pointer.
When we say P[0](&a,b) , P[1](&a,b).It is same as f1(&a,b) ,f2(&a,b) respectively.
In this program the function f1(),f2() are using the concept called call by reference and call by value.The first parameter to both the functions is call by reference and second parameter is call by value.
So in functions f1() and f2(),we are trying to swap the contents.But we are passing address of the variable a only.So,changes made in the calling function will be reflected to the called function.But it won't happen with b,as it is call by value.
Hence the output.
Correct
ReplyDeleteWell done Soumen !