...
Question 5120 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5122 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5120 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023
Question 5122 – UGC NET CS 2018 JUNE Paper-2
December 1, 2023

Question 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.
A
(a) only
B
(b) only
C
(c) only
D
(b) and (c) only
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!