asked 162k views
4 votes
Swapping the contents of two variables requires a third variable that can serve as a temporary storage location. True False.

asked
User DrYap
by
8.8k points

1 Answer

2 votes

Answer:

True.

Explanation:

True.

Let's say A = 5, and B = 10.

We need to swap the contents of A and B, so A will end up with 10 and B will end up with 5.

A = 5

B = 10

Introduce variable C.

C = A (now C contains 5)

A = B (now A contains 10)

B = C (now B contains 5)

In the last two steps above, you see that the values of A and B were swapped.

answered
User Yamass
by
7.7k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.