...
Question 6922 – UGC NET CS 2015 Dec – paper-3
April 14, 2024
Programming
April 14, 2024
Question 6922 – UGC NET CS 2015 Dec – paper-3
April 14, 2024
Programming
April 14, 2024

Programming

Question 6

What does the following code do?

 var a, b : integer;
 begin
    a:=a+b;
    b:=a-b;
    a:=a-b
 end; 
A
exchanges a and b
B
doubles a and stores in b
C
doubles b and stores in a
D
leaves a and b unchanged
E
none of the above
Question 6 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
Correct Answer: A
Question 6 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

Leave a Reply

Your email address will not be published. Required fields are marked *