Program to swap the values of two variables.
Code:
a = 10;
b = 20;
temp=0;
print("Before swapping: ")
print("a: ",a)
print("b: ",b)
temp=b;
b=a;
a=temp
print("After swapping: ")
print("a: ",a)
print("b: ",b)
Output:
Code:
a = 10;
b = 20;
temp=0;
print("Before swapping: ")
print("a: ",a)
print("b: ",b)
temp=b;
b=a;
a=temp
print("After swapping: ")
print("a: ",a)
print("b: ",b)
Output:
Comments
Post a Comment