Computer Science, asked by priyankajangid2150, 1 year ago

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

Answers

Answered by mariospartan
4

Explanation:

first=int(input(“enter the first value “))

second=int(input(“enter the second value”))

third=int(input(“enter the third value”))

first=first+second

second=first-second

first=first-second

print(first,second)

second=third+second

third=second-third

second=second-third

print(second,third)

Here we get all the three inputs and store in "first, second and third" respectively. Then we perform operations to swap first two variables with the sum of first and second and then print the value. Next we do the same with second and third numbers.

Another method:

a, b, c = map(int, input('Enter three numbers : ').split())

a, b = a+b, b+c

print(a, b, c)

To Learn more:

https://brainly.in/question/1089725

https://brainly.in/question/5932806

Similar questions