xxxxxxxxxx
num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
print("Value of first number before swapping is" , num1)
print("Value of second number before swapping is" , num2)
store_flag = num1
num1 = num2
num2 = store_flag
print("Value of first number after swapping is" , num1)
print("Value of second number after swapping is" , num2)
xxxxxxxxxx
// Method 1: With temporary variable
temp = A
A = B
B = temp
// without temporary variable
// Method 2: Addition and subtraction
A = A + B
B = A - B
A = A - B
// Method 3: Muitply and Divide
A = A * B
B = A / B
A = A / B
xxxxxxxxxx
#include<stdio.h>
int main()
{
int x = 20, y = 30, temp;
temp = x;
x = y;
y = temp;
printf("X = %d and Y = %d", x, y);
return 0;
}