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 are all the things ur going to keep in mind while System testing?

2 Answers  


How to explian the V model ?

1 Answers   Crea,


What is difference between Sanity Testing & smoke Testing?

1 Answers  


When we have to use Boundary value analysis and when to use equivalence partitioning. Please explain with an example. Urgently required.

2 Answers  


1> Which is the latest technology use for login page? 2> What is virtual keyboard? Is it more secure than key board?

1 Answers  






I write the test cases in Excel Sheet. For Retesting how to maintain the excel sheet.? Hw to maintain the History?

2 Answers  


If there is a button called Edit button. 1) Editing can be done by double clicking the object 2) Editing can be done by pressing Edit button 3) Editing can be done by pressing Alt+E key Then Should I have to write 3 different test cases for editing object? What should I do so that I 'll not miss the any functionality while testing.

1 Answers  


Hi can any one plz answer me how to set up the test environment does it done by tester it self? its urgent thanks in advance roli

3 Answers   Cap Gemini,


what is mean by object oriented design?how is testing affected by object oriented designs?

1 Answers  


What is CMMI?

1 Answers  


What made you pick testing over another career?

1 Answers  


What is the goal of Software Configuration Management(SCM? a.)Configuration Identifier b.)Configuration Control c.)Process Management d.)All options.

2 Answers   Amdocs,


Categories