swapping |
Swapping is the process of exchanging the value from the main memory to secondary memory for temporary purposes so that the main memory will be free for other purposes. Let's be clear with the given example:-
Swapping the value of 3 different numbers number
Initially,
a = 5; b = 10; c;
c = a; | c = 5 |
a = b; | a = 10 |
b = c; | b = 5 |
Now let's see same work in 2 different numbers,
Initially,
a = 10;
b = 20;
a = a + b | a = 10+20 (30) |
b = a-b | b = 30-20 (10) |
a = a-b | a = 30-10 (20) |
let's be clear with the flowchart
Let's see the program here for this,
OUTPUT
The value of a is 20
The value of b is 10
0 Comments