World Languages, asked by kmahek844, 3 months ago

Write an algorithm for swapping two numbers using third variables in python

Answers

Answered by prasiddhiswami8
2

Answer:

Algorithm : a. using a third variable

  • Step 1 : Start.
  • Start 2 : READ num1, num2.
  • Start 3 : temp = num1.
  • Start 4 : num1 = num2.
  • Start 5 : num2 = temp.
  • Start 6 : PRINT num1, num2.
  • Start 7 : Stop.

Explanation:

Hope it helps you:-

Answered by daisy3615
0

Swapping of two numbers (using a third variable)

a=int(input("Enter value of a "))

b=int(input("Enter value of b "))

c=int(input("Enter value of c "))

print("Value of a before swapping",a)

print("Value of b before swapping",b)

a=b

b=c

c=a

print("Value of a after swapping",a)

print("Value of b after swapping",b)

Hope it helps!

Just realized this question is a year old but ima leave this here for others who might need it ^^

Similar questions