I have four questions that I cannot be sure i have correct for my vb class. I am going insane and it is due tomorrow.
Please help if you can and tell me why you think I am wrong and why it should be a certain value I would be SO grateful!
Here are the 4 questions.
1.What value will be returned by the following function assuming that "ABBCCCDDD" is passed in to the S parameter?
Private Function Quest1(ByVal S As String) As Integer
Dim ndx AS Integer
Dim cnt As Integer = 0
For ndx = 1 To Len(S) -1
If Mid(S, ndx, 1)= Mid(S, ndx +1, 1) Then cnt= cnt+1
Next
Quest1= cnt
End function
Is the anwnser 4 or 5 or 6 or none of the above it will return _____
I keep thinking it is 5.
Ok 2nd one
What value will be returned by the following funtion assuming 10 is passed to the max parameter?
Private Function Quest2(ByVal Max As Interger) As Integer
Dim ndx AS Integer
Dim cnt As Integer = 0
For ndx = 1 To Max Step 2
cnt = cnt +1
Next
Quest2= cnt
End function
Pick:
4, 5, 6 or none of the above it will return____
I say 5 again?
ok 3rd:
What value will be returned by the following function assuming 4 is passed to the Max parameter?
Private Function Quest3(ByVal Max As Interger) As Integer
Dim ndx AS Integer
Dim ndx2 As Integer
Dim cnt As Integer = 0
For ndx = 1 To Max
For ndx2 = 1 To 3
cnt = cnt + 1
Next
Next
Quest3= cnt
End function
Pick:
4, 5, 6 or none of the above it will return____
I say none of the above it will return 12???
Next one:
For which of the supplied values will fuction Quest4 return True? (circle all that apply)
Private Function Quest4(ByVal S As String) As Integer
Dim ndx As Integer
Dim cnt As Integer = 0
For ndx = 1 To Len (S) \ 2
If Mid(S, ndx, 1) <> Mid(S, Len(S) - ndx + 1, 1) Then
Quest4 = False
Exit Function
End If
Next
Quest4= Ttue
End function
Pick:
"ABBA"
"BAAB"
"ABA"
""
I say ??????
Please help if you can and tell me why you think I am wrong and why it should be a certain value I would be SO grateful!
Here are the 4 questions.
1.What value will be returned by the following function assuming that "ABBCCCDDD" is passed in to the S parameter?
Private Function Quest1(ByVal S As String) As Integer
Dim ndx AS Integer
Dim cnt As Integer = 0
For ndx = 1 To Len(S) -1
If Mid(S, ndx, 1)= Mid(S, ndx +1, 1) Then cnt= cnt+1
Next
Quest1= cnt
End function
Is the anwnser 4 or 5 or 6 or none of the above it will return _____
I keep thinking it is 5.
Ok 2nd one
What value will be returned by the following funtion assuming 10 is passed to the max parameter?
Private Function Quest2(ByVal Max As Interger) As Integer
Dim ndx AS Integer
Dim cnt As Integer = 0
For ndx = 1 To Max Step 2
cnt = cnt +1
Next
Quest2= cnt
End function
Pick:
4, 5, 6 or none of the above it will return____
I say 5 again?
ok 3rd:
What value will be returned by the following function assuming 4 is passed to the Max parameter?
Private Function Quest3(ByVal Max As Interger) As Integer
Dim ndx AS Integer
Dim ndx2 As Integer
Dim cnt As Integer = 0
For ndx = 1 To Max
For ndx2 = 1 To 3
cnt = cnt + 1
Next
Next
Quest3= cnt
End function
Pick:
4, 5, 6 or none of the above it will return____
I say none of the above it will return 12???
Next one:
For which of the supplied values will fuction Quest4 return True? (circle all that apply)
Private Function Quest4(ByVal S As String) As Integer
Dim ndx As Integer
Dim cnt As Integer = 0
For ndx = 1 To Len (S) \ 2
If Mid(S, ndx, 1) <> Mid(S, Len(S) - ndx + 1, 1) Then
Quest4 = False
Exit Function
End If
Next
Quest4= Ttue
End function
Pick:
"ABBA"
"BAAB"
"ABA"
""
I say ??????
