+ 2

how to swap a number without using third variable and without alphabetic letters

27th Oct 2016, 10:05 PM
samanth kumar
samanth kumar - avatar
3 odpowiedzi
+ 7
I'm not sure if this is what you want: but if you have two numbers, you can swap them without a third variable with a code like this: firstNum += secondNum; secondNum = firstNum - secondNum; firstNum -= secondNum;
27th Oct 2016, 11:42 PM
Nelson Urbina
Nelson Urbina - avatar
+ 2
suppose i have 2 variables a=5 and b=4 and we want to swap values without any other variable then a=a+b ; // a=9 new value b=a-b; // b=9-4=5 a=a-b; // a=9-5 =4
6th Nov 2016, 6:10 PM
Mukesh Kumaar
Mukesh Kumaar - avatar
0
can you explain what you whant to do a bit better please?
27th Oct 2016, 10:26 PM
Luka Bjelica
Luka Bjelica - avatar