X=10,Y=20 you need to swap the numbers without using a
third variable?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
'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 |
how to post xml data from QTP scripts to any application?
why qtp supports vbscript? and not for others just like cgi,phython,shell,perl,html and all..
What is keyword driven framework, what is "key" in It.
Can we add the function library directly from scripting in qtp instead of adding from resource tab?
Explain the check points in QTP?
what is keyword driven framework in qtp.
How do you do batch testing in QTP, if so explain?
While writing script using For Next Statement in QTP, I try defining the variable in Lib File I am getting syntax error whereas if I use the variable in script file, the script works fine. Can anyone help me in finding the reason behind this?. E:g Dim intStartRow (Define in Lib File----- say abc.vbs) Dim intRow (If I define this variable in Lib file I am getting Syntax error where as if I define in the script file ---- say xyz.mts the script works fine) IntStartRow=2 For intRow = intStartRow to xlWrksht.UsedRange.Rows.Count ‘Some Code here Next
Difference between copy to action and call to action?
Does QTP run in any environment?
Tell me about qtp?
What is the difference between keyword driven frameworkd and Modularisation framework?(Chandana)