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 are the views available in quicktest professional?

0 Answers  


Without QTP (or any Testing tool) can we able to test the GUI part of the Applications. for Example generating the Scripts in Notepad and Executing them Using VB. Is it Possible to do so..

2 Answers  


What is Descriptive Programing? In which cases, we will go for descriptive programing?

2 Answers   CTS,


how to use the QTP choose the data from oracle? e.g. i input the identity card NO. this will be add new record in the database ,and now i want get this record's prime key.

0 Answers  


1.how can we report the QTP test result in a different excel sheet 2.

3 Answers   Aurigo,






Tell me about qtp?

0 Answers  


How u call functions in QTP Function to calculate the length of characters in a wor

2 Answers  


Explain the types of object repository?

0 Answers  


What r the advantages of automation?

3 Answers  


Hi, I am new to QTP testing and was exploring the frameworks used for automation. I wanted help in writing various scripts and files for keyword driven automation like 1. Control File 2. Test Case File 3. Startup Script 4. Driver Script 5. Utility Script . etc It would be great if someone can give help in this context ... Thanks

0 Answers  


how can we test the Triggers, Cursors, Indexes while doing Database testing in DTP??

0 Answers   ABC,


What are objects? how do you select the unknow object?

3 Answers  


Categories