Swap 2 variables without using a temp variable

Answers were Sorted based on User's Feedback



Swap 2 variables without using a temp variable..

Answer / guest

a,b
a=a+b
b=a-b
a=a-b

Is This Answer Correct ?    21 Yes 0 No

Swap 2 variables without using a temp variable..

Answer / sheetal

if a=5 and b=3 are two variables, then add them i e
a=a+b; a=8
b=a-b; b=5
a=a-b; a=3

Is This Answer Correct ?    12 Yes 0 No

Swap 2 variables without using a temp variable..

Answer / mfsi_satyakamm

int x,y;
x=x+y;
y=x-y;
x=x-y;

Is This Answer Correct ?    12 Yes 1 No

Swap 2 variables without using a temp variable..

Answer / s n

try this one line swaping of two variables


a=((a+b)-(b=a));

Is This Answer Correct ?    3 Yes 5 No

Post New Answer

More Manual Testing Interview Questions

What is a checklist? and wat are its contents??

4 Answers  


what responsility of the network administrator?

1 Answers   Religare,


I don't know about testing, I want to learn about Teasting. What kind of books I should read? Can anyone help me? (Like manual, automated testing) lots of things are there. from where I should start?

2 Answers  


What is test matrics?

6 Answers   Wipro,


what is test data?how test data is prepared? are there any guidelines/methods to prepare it?

4 Answers  






for example, we have old password,confirmed password, new password followed by submit button. what are the test cases written for that?

9 Answers   Semantic Space,


What is difference between web based testing and windows based testing ?

4 Answers   CSS,


What are the test cases for the fields, Name, Password, Login id, Address, phone,etc.?

1 Answers  


What are the disadvantages of manual testing?

0 Answers  


what are the release notes and what release note contains, when these prepared.

3 Answers   HCL,


my mail id is mudaseer123@gmail.com and password:qwertyiop but if i enter mail id in capital letters and password correctly should then what will happen?does it display login failed?

1 Answers  


how to test ecg machine?

0 Answers  


Categories