Wednesday, October 7, 2015

Merging Two Arrays and convert as String QTP

Dim A(1)
A(0) = "Guru"
A(1) = "Prasad"
Dim B(1)

B(0) = "Naidu"
B(1) = "Kollu"
For i = 0 to ubound(A)
Str = A(i)
oTempA = oTempA&","&Str
Next
For j= 0 to ubound(B)
Str1 = B(j)
oTempB = oTempB &","& Str1
Next
        strCon = oTempA &""& oTempB
msgbox strCon

Saturday, October 3, 2015

QTP MNC Interview Quesions


  • Print next prime number in given number
  • Merge two arrays
  • Sorting of given string 

Note : Post a comment for solution on any questions

Thank you for visiting blog

How to sort the array of Integer in QTP ?

Ascending 

arr=Array(460, 68, 2, 7, 3, 5, 1)

For i=ubound(arr)-1 to 0 step-1
 For j=0 to i
  If arr(j) >arr(j+1) Then
   temp=arr(j+1)
   arr(j+1)=arr(j)
   arr(j)=temp
        End If
 Next
Next


'sorting an array in descending order

 arr=Array(4627351)
For i=ubound(arr)-1 to 0 step-1
 For j=0 to i
  If arr(j) 1Then
                        temp=arr(j+1)
   arr(j+1)=arr(j)
   arr(j)=temp
        End If
 Next
Next


msgbox arr(0)
msgbox arr(1)
msgbox arr(2)
msgbox arr(3)
msgbox arr(4)
msgbox arr(5)
msgbox arr(6)