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 API

1 Answers  


OPening of notedpad in QTP to write and execute the coding?

2 Answers  


what is descriptive programming?

5 Answers   Ordain Solutions,


Your roles and responsibilities and daily tasks? (As automation tester)

0 Answers   Oracle,


In my Script Firstly i have to parametrize the data then we import the data from c drive.suppose i have parametrize the Person name and company Name and i have enter one person name and one company name in the excel sheet now we import the sheet and the script is passed i want to ask one thing can we add more than one person name and more than one company name in the excel sheet suppose firstly we create person name "ADDy" and company nmae.'Wipro" and we set the current row in the script for this data and now we want run the script another set of data so how we can run the script with another set of data

2 Answers  


Is there any relation between Keyword Driven Framework and Recording modes provided in QTP( whether Recording modes are applied on keyword driven framework or not?)

0 Answers   IBM,


which tpye of exceptions mostly do we face in QTP

2 Answers  


what is option explicit? what is the use of it?

9 Answers   Syntel,


When you open QTP, how many sheets you can see?

0 Answers   Wells Fargo,


How you can delete excel file in qtp?

0 Answers  


how do find current links in webpage for ex: in yahoowebsite today mainpage is having 50 links and next day same page is having 60 links. if i run same programe it should display total links in webpage ?

4 Answers   CTS,


how u conduct GUI testing and PERFORMANCE testing on MS- WORD? and What r the GUI Test Cases and performance Test Cases?

3 Answers   Accenture, Civil Service, ICICI, Jintek, Satyam, Singularity, Syntel, TCS, Wipro,


Categories