Swap
Time Limit: 2 sec
Memory Limit: 128000 kB
Memory Limit: 128000 kB
Problem Statement
Given two elements A and B, your task is to swap the given two elements.
Input
User Task:
Since this will be a functional problem, you don't have to take input. You just have to complete the function Swap().
Since this will be a functional problem, you don't have to take input. You just have to complete the function Swap().
Output
You don't need to print anything, you just need to swap the given elements.
Example:
Sample Input:-
A = 5, B = 7
Sample Output:-
A = 7, B = 5
Sample Input:-
A = 3, B = 6
Sample Output:-
A = 6, B = 3
A = 5, B = 7
Sample Output:-
A = 7, B = 5
Sample Input:-
A = 3, B = 6
Sample Output:-
A = 6, B = 3
// A: contains first value
// B: contains second value
// You need to just swap the values
static void Swap(){
//Enter your code here
// 1 // A = A + B;
// B = A - B;
// A = A - B ;
// 2 // A = A * B;
// B = A / B;
// A = A / B ;
// 3 // A = (A * B) / (B = A);
// A = A ^ B;
// B = A ^ B;
// A = A ^ B;
A = (A & B) + (A | B);
B = A + (~B) + 1;
A = A + (~B) + 1;
}