Question 6922 – UGC NET CS 2015 Dec – paper-3
April 14, 2024Question 10439 – Programming
April 14, 2024Question 10422 – Programming
What does the following code do?
var a, b : integer; begin a:=a+b; b:=a-b; a:=a-b end;
Correct Answer: A
Question 48 Explanation:
Exchanges a and b.
Let us consider a=5; b=2
a := a+b = 5+2 = 7
b := a-b = 7-2 = 5
a := a-b = 7-5 = 2
O/P: a=2; b=5
Let us consider a=5; b=2
a := a+b = 5+2 = 7
b := a-b = 7-2 = 5
a := a-b = 7-5 = 2
O/P: a=2; b=5
exchanges a and b
doubles a and stores in b
doubles b and stores in a
leaves a and b unchanged
none of the above
Subscribe
Login
0 Comments