Computer Science
Write a program to read three numbers in three variables and swap first two variables with the sums of first and second, second and third numbers respectively.
Python
Python Funda
198 Likes
Answer
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
print("The three number are", a, b, c)
a, b = a + b, b + c
print("Numbers after swapping are", a, b, c)
Output
Enter first number: 10
Enter second number: 15
Enter third number: 20
The three number are 10 15 20
Numbers after swapping are 25 35 20
Answered By
125 Likes
Related Questions
Write a program to compute simple interest and compound interest.
Write a program to input a number and print its first five multiples.
Write a program to read details like name, class, age of a student and then print the details firstly in same line and then in separate lines. Make sure to have two blank lines in these two different types of prints.
Write a program to input a single digit(n) and print a 3 digit number created as
e.g., if you input 7, then it should print 789. Assume that the input digit is in range 1-7.