X=10,Y=20 you need to swap the numbers without using a
third variable?

Answers were Sorted based on User's Feedback



X=10,Y=20 you need to swap the numbers without using a third variable?..

Answer / bhaskar

X=X+y
Y=X-Y
X=X-Y

Is This Answer Correct ?    27 Yes 6 No

X=10,Y=20 you need to swap the numbers without using a third variable?..

Answer / venki

x=10 and y=20
x=x+y
=>x=10+20=30
=>x=30
y=x-y
=>y=30-20=10
=>y=10 ----->@1
x=x-y
=>x=30-10=20
=>x=20 ----->@2
now x and y values has been swaped
see @1 and @2

Is This Answer Correct ?    13 Yes 0 No

X=10,Y=20 you need to swap the numbers without using a third variable?..

Answer / test

Dim a,b
a=10
b=20
a = a + b
b = a - b
a = a - b
Msgbox a
msgbox b

Is This Answer Correct ?    9 Yes 0 No

X=10,Y=20 you need to swap the numbers without using a third variable?..

Answer / sandip patil

If X=10 & Y=20
then for swapping just go with following

Y=Y-X i.e. Y=20-10=10 here value of Y=10
X=X+Y i.e. X=10+10=20 Here value of X=20

It is swap

Is This Answer Correct ?    4 Yes 3 No

X=10,Y=20 you need to swap the numbers without using a third variable?..

Answer / ramyashetty

'a and b are two variables ; Following code swaps both number and string inputs

a = Inputbox("Enter a")
b = Inputbox("Enter b")


a = a + b

b = left(a,(instr(a,b)-1))
a = Right(a,(len(a)-len(b)))

msgbox "b ="&b
msgbox "a = "&a

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More QTP Interview Questions

What is Modular framework and Keyword drive framework? Explain

4 Answers  


Which Databases supports for QTP?

2 Answers  


How many ways we can parameterize data in QTP?

1 Answers   Crea,


WHAT IS THE DIFFERENCE BETWEEN QTP SCRIPT AND VB SCRIPT? HOW MUCH PERCENTAGE WE USE IN QTP SCRIPT REAL TIME AND HOW MUCH PERCEN OF VB SCRIPT,,,,,,,

0 Answers  


what is impact analysis on regression testing?

0 Answers   L&T,






How to remove associated function library?

0 Answers  


What is the diff between doing parametarisation using Data Driven wizard or manually. when do we go for manual para...and when do we use Data driver wizard..can anybody answer it ..Thanks in advance

6 Answers   Siemens,


What is test automation framework?which framework does QTP follow?Need some practical explanation as to how u will start ur testing process following a particular framework?

2 Answers   IBM, Sony,


Is there any option in QTP to add Java add-in after instaling the QTP?

3 Answers   IBM,


Hi All, I am new to QTP but i was trained on winrunner before. My problem is..QTP 8.2 was unable to record my application which is a java app. By selecting smart identification, i was somehow able to record the test BUT QTP cant run the test! Can anyone help me in walking through this problem..Is java addin really necessary for this?? Is there anyways i can run the test successfully? I am not sure whats going wrong in my testing.Please do help me asap as i need to submit the report early. Thanks in advance

4 Answers  


is qtp 9.2 create the scripts with the application run on mozilla firefox browser?

3 Answers  


How should I click on the right click menu objects When I trying to add the object properties to the OR.It is showing only Window(Window).Not all the objects of the window. Also while recording I found No script. How to solve this>.

0 Answers  


Categories