1.7 Which is the correct sequence of statements that swaps values of two variables?
A) a=a+b; a=a-b; b=a-b;
B) a=a+b; b=a-b; a=a-b;
C) a=a-b; a=a+b; b=b-a;
D) None of the Above
Which is the correct sequence of statements that swaps values of two variables?
in C and CPP
aditya singh
Correct answer is B
eg:
a=5; b=3;
a = 5 + 3 ans. 8
b = 8 – 3 ans. 5
a = 8 – 5 ans. 3
final result
a = 3;
b = 5;
swap complete