Online GK Series

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

One Year MBA At Rs.7500/- Only Apply Now

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;

Your Valuable Comments Please...

Useful Computer Science EBooks