The instructions: x = x + y y = x - y x = x - y result in:

2015

The instructions: x = x + y y = x - y x = x - y result in:

  1. A.

    Retain the values of x and y

  2. B.

    Complement the value of x and y

  3. C.

    Swap x and y

  4. D.

    Negates x and y

  5. E.

    Question not attempted

Attempted by 1104 students.

Show answer & explanation

Correct answer: C

Step 1: Start with initial values of x and y.

Step 2: After x = x + y, x becomes the sum of the original values of x and y.

Step 3: After y = x - y, y becomes the original value of x (since x is now x + y, and subtracting y gives back the original x).

Step 4: After x = x - y, x becomes the original value of y (since x is now x + y, and subtracting the new y (which is original x) gives back the original y).

Thus, the values of x and y are swapped.

हिन्दी उत्तर:

चर x और y के शुरुआती मानों से शुरू करें।

x = x + y के बाद, x मूल x और y का योग बन जाता है।

y = x - y के बाद, y मूल x का मान बन जाता है (क्योंकि x अब x + y है, और y घटाने पर मूल x मिलता है)।

x = x - y के बाद, x मूल y का मान बन जाता है (क्योंकि x अब x + y है, और नए y (जो मूल x है) को घटाने पर मूल y मिलता है)।

इस प्रकार, x और y के मान आपस में बदल जाते हैं।

Explore the full course: Up Lt Grade Assistant Teacher 2025