Question 5120 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023Question 5122 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023Question 5121 – UGC NET CS 2018 JUNE Paper-2
Given below are three implementations of the swap( ) function in C++ :
Which of these would actually swap the contents of the two integer variables p and q ?
Correct Answer: B
Question 5 Explanation:
Module -(a) is call by value , so by using that code w can not swap the contents.
Module -(b) is call by reference , So the modification of content in the function reflects the changes in the main program. Swapping is done in the module -(b).
Module -(c) is passing addresses as parameters but in the functions definition , We are changing the addresses not the content So swapping of the values can’t be done.
Module -(b) is call by reference , So the modification of content in the function reflects the changes in the main program. Swapping is done in the module -(b).
Module -(c) is passing addresses as parameters but in the functions definition , We are changing the addresses not the content So swapping of the values can’t be done.
(a) only
(b) only
(c) only
(b) and (c) only
Subscribe
Login
0 Comments