swap variables without temp

Solutions on MaxInterview for swap variables without temp by the best coders in the world

showing results for - "swap variables without temp"
Filippo
04 Sep 2020
1# Swap without using any temp variable
2x = 66
3y = 77 
4
5print("Original: ", x,y)
6
7x = x - y
8y = x + y
9x = y - x 
10
11print("Swapped 1st time: ", x,y)
12
13x = x + y
14y = x - y
15x = x - y 
16
17print("Swapped 2nd time: ", x,y)
18
19# Output:
20# Original:  66 77
21# Swapped 1st time:  77 66
22# Swapped 2nd time:  66 77 
Ilyess
19 Feb 2020
1import java.*; 
2  
3class noTemp { 
4  
5    public static void main(String a[]) 
6    { 
7        int x = 10; 
8        int y = 5; 
9        x = x + y; 
10        y = x - y; 
11        x = x - y; 
12        System.out.println(x , y); 
13    } 
14} 
queries leading to this page
swap 3 numbers without using tempswap two numbers without third variableswapping digits in a number pythonhow to swap a 4 digit in python4 write a program to take two input from user and swap its value using third variable python swap digits in integer pythonhow to swap three number in pythonswap 2 nos in pythonhow to swap no in pythonpython function to swap two numbers real pythwhere python swapping is not possibleswap two numbers without using tempswap numbers in string pythonpyton swap casesswapping two numbers in phytonhow to swap numbers in pythonhow to switch two variables in pythonswap digits in pythonpython swappython exchange variable valuesswap value pythonhow to swap it pythonhow to swap in pythonwap to swap to numbers in pythonhow to swap two variable inlist pythonswapping of two numbers in pythonswap variables python valueshow to swap between two number in pythonpython swap numbersswap no using numpyswap 3 numbers without temphow can we swap two numbers in pythonpython swap functionswap variables without tempswap without using third variableswap number position pythonhow to swap variables without tempswap numbers without using third variable pythonswap i and i 1 in pythonswap two no in pythonswaping first two numbers of a integer value in pythonswap two variables without temporary javaswap 2 numbers without using 3rd variable pythonfunction to swap 2 numbers in pythonhow to swap more than two variables in python3how to swap without temporary variableswap the valuesswap in pythonswapping without temporary variablehow to swap two numbers in pythonswap two numbers in pythonpython swap varspython 3 swappython program to swap two variableswap using third variable in pythonswapping of two variables in pythonswapping in python shprtcutpython swap valuesswapping variables with a temppython switch values of variablesswap variable values pythonpython swapping two variableshow to do a swap in pythonto swap in pythonsoup numers in pythoncode model swapping pythonswaping without tempfunction that swaps two integers pythonswap 2 elements without tempswap values function in pythonswap digits pythonswap 2 numbers using xorconsider a 3d2 2c b 3d3 how will you write a funtion which swap this two numbers with out using third variable input 3a a 3d2 2c b 3d3 output 3a a 3d3 2c b 3d2 using pythonhow to swap the digits of a number in pythonpython how tostort number with swapinstant swap variables pythonswapping two numbers pythonpython how to swap valueswrite a program to swap two numbers in pythonpython digit swapswapping two no in pythonwrite a program to swap two variable without using temp variable swap number in pythonswap 3 variables in pythonswap number without tempswap values of variables begins in pythonpython code to switch value of variableshow many method for swap number in pythonswap to numbers without tempswap two numbers without temporary variablehow to swap integers in pythonhow to swap value in pythonswap using temphow to swap between variables without tempdigit swap infinite numbers pythonhow to swap more than two variables in python 4 write a program to take two input from user and swap its value using third variable pythonswapping 2 numbers in pythonswaping digits of a integer in pythonswapping numbers without temp variableswap a number in place pythonpython exchange valuesswaping in pythonhow do i swap digits in pythonswapping of two numbers using function in pythonpython swap two variablesswap of two numbers in pythonpython program to swap numbersswap two numbers without using third variablespython program to swap two numebersswap numbers pythonhow to swap two numbers in variables in pythonswap two numbers without using third variable in phythonhow to swap values in pythonhow to swap variable values on pythonswapping without using temp variableswapping numbers in pythonswapping numbers around in pythonpython program to swap two numbershow to swap variables values pythonswap two numbers without temppython digit swap using mathpython program to wap to swap two numbersswitch two variables pythonswap in pythonswap adjacent digits of a number in pythonswap 2 numbers without tempswap 2 variables without using thirdpython swar valueswitch variablesswap withoyut temp variableswapping without tempswap of two numbers in pyhonpython swap integersswap to no without using temphow can we swap two numbers a 3d 10 b 3d 20 in python without using third variable 2aswap two numbers without using third variablepython function to swap two numbers shanlini becomes hslina swap in pythonpython swap 2 valuesswap numbers in python without using third variableswap value function in pythonswapping of two numbers pythonswap in python examplepython fastest way to swap two valuesswap of two number in pythonhow to swap i and i 2b1 in pythonswap two numbers pythonpython swap int from 0 and 1how to swap nos in pythonfunction to swap 2 numbers pythonhow to swap variables in pythonwrite a python program to swap two user defined variables 28not 3a user can enter any type of data choose input type accordingly 29how to swap digits in pythonswapping between two numbers in pythonswap two integers in pythonswap in array pythonswap two nos in pythonswap pythonfunction to swap two numbers in pythonhow to switch variable values in python6 write a python program to swap two variablesswap elements without temppython swap two numbersactivity 1 3a swapping numbers accept two numbers from the user store these numbers in two variables and swap the values of these variables how to write a python function that swap two numbersswapping digits in pythoninteger swapping pythonswaping numbers in pythonpython code to swap two numberswrite python program to swap two numbers without using intermediate 2ftemporary variables prompt the user for input swap two number around pythonswap two variables in pythonswap without tempswapping to integer in pythonswap numbers in pythonpython program to swap two variablesswap 2 numbers in pythonswap variables without temp