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 type of VB script u had done in expert view?

1 Answers   HCL,


requirement is for combo box your expected value is str= "Denver.Frankfurt.London.Los Angeles.Paris.Portland.San Francisco.Seattle.Sydney.Zurich" you must get the text in combo box and need to compare them how

0 Answers   FIS,


if the excel sheet specified in script is not there,we get run time error how to handle the error ,please anybody explain me in detail

2 Answers   Quinnox,


How i can use and create Library functions in QTP and what is the proces .

2 Answers  


Idid my qtp course in 2007 june in mind Q i for got to use this tool ,i want to mention in my resume about this ,how can i rectify this ,pls give me any idea .

2 Answers   Quest,






How to export QTP results to an ".xls" file?

3 Answers  


can anyone tell me what to say in interview when interviewer asks about "tell me about your framework in your project"?

0 Answers  


What is the use of "Registeruserfunc" when should we use it? Note:Please do not copy paste the date from QTP help. I tryed it.But I don't Understand where should we use exactly.

5 Answers   Livetek,


hi i have one isuue on selecting webcheckbox .there are 15 wecheckboxex i want to select every time 9 th one how can i select plese help me regards balaji

4 Answers  


Explain building blocks of the bpt framework ?

0 Answers  


How can we export test results to an excel sheet in QTP??? Can any one provide sample coding for this?????

6 Answers   TCS,


where is the bitmap checkpoint be saved

1 Answers  


Categories