swap 2 variables without using 3 rd variable???

Answers were Sorted based on User's Feedback



swap 2 variables without using 3 rd variable???..

Answer / rajendra

let
A=10
B=20
after swaping A=20
B=10
ok
A = A + B (A = 20+10 = 30)
B = A - B (B = 20-10 = 10)---->B=10
A = A - B (A = 30-10 = 20)---->A=20
Thats all very simple

byee Friends
rajendra
rajendra prasad reddy
rajendra_penumalli@yahoo.com
9885162742
hyd

Is This Answer Correct ?    9 Yes 3 No

swap 2 variables without using 3 rd variable???..

Answer / david

a^=b
b^=a
a^=b

Is This Answer Correct ?    1 Yes 1 No

swap 2 variables without using 3 rd variable???..

Answer / viji

you can go swap function
swap(a,b)

Is This Answer Correct ?    0 Yes 0 No

swap 2 variables without using 3 rd variable???..

Answer / guest

Ex:
1.
A=20,B=10
A=A-B=20-10=10
B=A+B=10+10=20
A=B-A=20-10=10

2.
A=6,B=4
A=A-B=6-4=2
B=A+B=2+4=6
A=B-A=6-2=4

The above logic works if A>B. If B>A:

B=6, A=4
B=B-A=6-4=2
A=A+B=4+2=6
B=A-B=6-2=4

Is This Answer Correct ?    0 Yes 0 No

swap 2 variables without using 3 rd variable???..

Answer / padma

Manual testing can be carried out using data validation and
data verification techniques as the function or piece of
code is entirely based on the variables.

Is This Answer Correct ?    0 Yes 0 No

swap 2 variables without using 3 rd variable???..

Answer / padmas

In The Manual Testing process, The team/member is not allowed to do any kind of code/unit or piece of code modifications. etc...,even though the members are aware of bug/ defect exists in the unit/code. Because the question falls under manual testing and even though I know how to do it, it is not out of the box question.

Is This Answer Correct ?    0 Yes 0 No

swap 2 variables without using 3 rd variable???..

Answer / gm

Before Swaping
A = 10
B = 20
After Swapping
A = 20
B = 10

Solution:
B = B - A =(20-10) = 10 ---> B = 10
A = A + B =(10+10) = 20 ---> A = 20 (since B = 10 now)

Is This Answer Correct ?    2 Yes 3 No

swap 2 variables without using 3 rd variable???..

Answer / naresh

rajendra is correct

but the example he took is wrong...

Is This Answer Correct ?    0 Yes 2 No

swap 2 variables without using 3 rd variable???..

Answer / hari

sorry your question is wrong

Is This Answer Correct ?    0 Yes 2 No

swap 2 variables without using 3 rd variable???..

Answer / manu

sorry rejendra but i think u r wrong
u hae initially takn a=10 and b=20
ut had taken opposite values moreovr when u have performed
the operation a=a+b
now the value of a has become 30 not the previous 1
i think this will be done with the use of temp variable

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More Manual Testing Interview Questions

in employe details form, we are entering First name as manjunath and Last name as sastry. but when we retriving the data in reports form, it shows as first name as sastry and last name as manjunath. here bug may be in employee details form or reports form. how you check in manual?

9 Answers   CTS,


what comments have u given in peer review? tell me at least 3 comments what u have given? july27 brahma412@yahoo.co.in

2 Answers   CTS,


smoke test as a example for naukri.com

3 Answers   TCS,


Training for Manual/QTP Testing from 6 years MNC experience engineer, working in Patni with Project .Guranteed Job training else fee back in Mumbai-mail-- >amol.dhumalatrediffmail dot com

0 Answers  


.what are the types of recording modes in winrunner 2.what are the three modes of running a test in winrunner 3.what is synchronization point 4.what are the contents present in a test case 5.do we need testing for the project 6.what is code review and code walk through At which phase the testing starts (begin) in the project How do we test Client server applications and a Web applications what is verification and validation what is adhoc testing what is traceability matrix what is base line document what is Test Life Cycle what is regression testing and retesting what is a BUG LIFE CYCLE what is a Bug what are defects what is functionality testing and system testing. a project has to be released in one day but the testing people got that project from the developers half of the day before so what they have to do to complete the testing process. 20 what are severity level and priority levels

1 Answers   Stag Computers,






HI frnds, can any one tel me..when a tester can starts test case writing? reply sooooon plss..

5 Answers   Polaris,


What is CMM?

3 Answers   Patni,


what is a test plan....... can any one explain me with an example.... and how to develop an test plan.........

4 Answers  


What is Configuration management? Tools used?

1 Answers  


What is srs and brs document?

0 Answers  


What are the different roles of testers in Verification and Validation?

2 Answers   Covansys,


Maximum how many defects found in a single module?

2 Answers  


Categories