Write VB script to test given number is Prime Number
Answers were Sorted based on User's Feedback
Answer / vijay kumar
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0 Then
count=count+1
End If
Next
If (count/2)<> 0 Then
print "given number is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 41 Yes | 14 No |
Answer / apoorva
bresult = False
Num = 907
For i = 2 To Num / 2
If Num Mod i = 0 Then
bresult = True
Exit For
End If
Next
If bresult = True Then
MsgBox "Prime"
Else
MsgBox "Not Prime"
End If
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / kishore
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0Then
count=count+1
End If
Next
If count>3 Then
print "given numer is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 31 Yes | 37 No |
Answer / prasanth
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0Then
count=count+1
End If
Next
If count>1 Then
print "given numer is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 8 Yes | 15 No |
Answer / rvanamala
'--------- "n" is a given number
n = 101
retval= PrimeNo(n)
If strComp(retVal,"1",1) =0 Then
MsgBox n &" is a Prime Number"
Elseif strComp(retVal,"0",1) =0 Then
MsgBox n &" is not a Prime Number"
Else
MsgBox n &" is -ve Number"
End If
'-------------------
Function PrimeNo(x)
k=0
z=0
If strComp(n,"0",1) = 0 Then
PrimeNo = 0
Exit Function
Elseif n < 0 Then
PrimeNo = -1
Exit Function
End If
For i = 1 to x
IsPrime = 0
If strComp(x,"1",1)= 0 Then
PrimeNo = 0
Exit Function
End If
z = x mod i
If eval("z = 0") and strComp(i,x,1) <>0 and
strComp(i,"1",1) <> 0 Then
PrimeNo = 0
Exit Function
Else
IsPrime= 1
End If
Next
PrimeNo = IsPrime
End Function
'-----------------------------------
Is This Answer Correct ? | 0 Yes | 10 No |
How many types of actions are there in quicktest professional (qtp)?
Suppose i have a script which is having 100 lines.I want to execute that script starting from line no 75.means first qtp should read the script from line no 75 how can u do it.
5 Answers Lehman Brothers, rsystems,
suppose u hav a dialog or window which contains 10 buttons with same name & value. now how to check each button? i.e. how qtp indetifies these objects separately?
Hello, I am facing problem to check textpoint for mercury application . I have inserted checkpoint to check flight summary for place of departure and arrival with datatable and script look like "Browser("Find a Flight: Mercury").Page("Book a Flight: Mercury").Check CheckPoint("Book a Flight: Mercury_4")" but while I am executing this script at last my check point gets fail and display Text Checkpoint: captured "" between Summary and 4/31/2008FLIGHT , expected "Acapulco" Match case: ON Exact match: OFF Ignore spaces: ON I think value from data table is not fatched so please guide me what I have to do to overcome this problem.. Thanks
Up to how much VB scripting knowledge and what type of VB script knowledge is required for a QTP test engineer for real time to work ?
can we run the scripts of qtp 8.2 in the qtp7.0?
Key word driven framework
1>How to get the browser name by writing the VBScript. 2>How did you used the GetROProperty and GetTOproperty .give real time scenario. 2>Give and real time ex for the bug having "High Severity and low priority"on banking doamin web based application.
Once the Actions are splitted , is there any way to merge them
What is the Limitations of Testing ?
I have two actions in my QTP test and two iterations in my DataSheet. I want to execute the Action 1 for the two iterations only after which i want to exceute the next Action2. How is this possible?
How to change the run-time value of a property for an object in QTP?