Online GK Series

This site is dedicated to the aspirants of competitive exams SSC, UPSC, Railways, Postal Assistants, Bank, GATE and NET

Q.

Which is the correct sequence statements that swaps values of two statements?

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 these
Answer & Explanation
Option: [B]

Let us test this with an example:

Let, a=20 and b=40. After swapping them a=40 and b=20

a=a+b; a=20+40=60;

b=a-b; 60-40=20;

a=a-b; 60-20=40;

Computer Science Books

Your Valuable Comments Please...

Please Like Us
Brand