suppose,a=1,b=2 and c=3, Write an algorithm to exchange the value of c and c will take the value of a
Answers
Answered by
0
Step-by-step explanation:
Swapping four variables without temporary variable
Suppose we have four variables a, b, c, d and we want to perform swapping of these variables in the following manner
a = b, b = c, c = d, d = a
without using any other fifth or temporary variable
Solution :
Step 1. Swap a and b without using any other variable
a = a + b
b = a – b
a = a – b
Step 2. Swap b and c without using any other variable
b = b + c
c = b – c
b = b – c
Step 3. Swap c and d without using any other variable
c = c + d
d = c – d
c = c – d
Answered by
0
sorry I don't know the answer
Similar questions