Deck 6: Repetition

ملء الشاشة (f)
exit full mode
سؤال
_________calculate the number of elements in lists.

A) Sentinels
B) Counter variables
C) Accumulators
D) Nested loops
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
A variable declared inside a Do loop cannot be referred to outside of the loop.
سؤال
What is wrong with the following simple password program where today's password is "intrepid"
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim password As String
password = InputBox ("Enter today's password:")
Do
lstBox. Items. Add ("Incorrect")
password = InputBox ("Enter today's password:")
Loop Until password = "intrepid"
lstBox. Items. Add ("Password Correct. You may continue.")
End Sub

A) There is no way to re-enter a failed password.
B) The Loop Until condition should be passWord <> "intrepid".
C) It will display "Incorrect." even if the first response is "intrepid".
D) Nothing
سؤال
A loop written using the structure Do While...Loop can usually be rewritten using the structure Do...Loop Until.
سؤال
What numbers will be displayed in the list box by the following code when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer = 7
Do
num += 1
lstBox.Items.Add(num)
Loop Until (num > 6)
lstBox.Items.Add(num)
End Sub

A) 7
B) 8
C) 7 and 8
D) 8 and 8
سؤال
If the loop is to be executed at least once, the condition should be checked at the__________ .

A) top of the loop
B) middle of the loop
C) bottom of the loop
D) Nothing should be checked.
سؤال
The following statement is valid.
سؤال
How many times will HI be displayed when the following lines are executed?
Dim c As Integer = 12
Do
lstBox.Items.Add("HI")
c += 3
Loop Until (c >= 30)

A) 5
B) 9
C) 6
D) 4
E) 10
سؤال
In the following code segment, what type of variable is counter?
Dim temp, counter, check As Integer
Do
temp = CInt(InputBox("Enter a number."))
counter += temp
If counter = 10 Then
check = 0
End If
Loop Until (check = 0)

A) counter
B) accumulator
C) sentinel
D) loop control variable
سؤال
In analyzing the solution to a program, you conclude that you want to construct a loop so that the loop terminates either when (a < 12) or when (b = 16). Using a Do loop, the test condition should be

A) Do While (a > 12) Or (b <> 16)
B) Do While (a >= 12) Or (b <> 16)
C) Do While (a < 12) Or (b <> 16)
D) Do While (a >= 12) And (b <> 16)
E) Do While (a < 12) And (b = 16)
سؤال
_________calculate the sums of numerical values in lists.

A) Sentinels
B) Counter variables
C) Accumulator variables
D) Nested loops
سؤال
When Visual Basic executes a Do While loop it first checks the truth value of the__________ .

A) pass
B) loop
C) condition
D) statement
سؤال
The following two sets of code produce the same output.
5 )\end{array}"> Dim num As Integer =1 Dim num As Integer =1 Do While nam <=5 Do  lstBox.Items.Add ("Hello")  lstBox. Items. Add ("Hello")  num +=1 num +=1 Loop  Loop Until (nam >5)\begin{array} { l l } \text { Dim num As Integer } = 1 & \text { Dim num As Integer } = 1 \\\text { Do While nam } < = 5 & \text { Do } \\\text { lstBox.Items.Add ("Hello") } & \text { lstBox. Items. Add ("Hello") } \\\text { num } + = 1 & \text { num } + = 1 \\\text { Loop } & \text { Loop Until (nam } > 5 )\end{array}
سؤال
The following are equivalent While and Until statements.
While (num > 2) And (num < 5)
Until (num <= 2) Or (num >= 5)
سؤال
What numbers will be displayed in the list box when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num as Double = 10 Do While num > 1 lstBox.Items.Add(num) num = num - 3 Loop End Sub

A) 10, 7, and 4
B) 10, 7, 4, and 1
C) 10, 7, 4, 1, and -2
D) No output
سؤال
A Do While loop checks the While condition before executing the statements in the loop.
سؤال
If the While condition in a Do While loop is false the first time it is encountered, the statements in the loop are still executed once.
سؤال
Which While statement is equivalent to Until num < 100?

A) While num <= 100
B) While num > 100
C) While num >= 100
D) There is no equivalent While statement.
سؤال
What is wrong with the following Do loop? Dim index As Integer = 1 Do While index <> 10 lstBox.Items.Add("Hello") index += 2 Loop

A) It should have been written as a Do Until loop.
B) It is an infinite loop.
C) The test variable should not be changed within the loop itself.
D) Nothing
سؤال
What is wrong with the following Do loop? Dim index As Integer = 1 Do While index <> 9 lstBox.Items.Add("Hello") index += 1 Loop

A) The test variable should not be changed inside a Do loop.
B) The test condition will never be true.
C) This is an infinite loop.
D) Nothing
سؤال
Which of the following are valid for an initial or terminating value of a Fir...Next loop?

A) a numeric literal
B) info.Length, where info is a string variable
C) a numeric expression
D) All of the above
سؤال
In a For statement of the form shown below, what is the default step value when the "Step c" clause is omitted?
For i As Integer = a To b Step c

A) the same as a
B) the same as b
C) 0
D) 1
سؤال
A For...Next loop with a positive step value continues to execute until what condition is met?

A) The counter variable is greater than the terminating value.
B) The counter variable is equal to or greater than the terminating value.
C) The counter variable is less than the terminating value.
D) The counter variable is less than or equal to the terminating value.
سؤال
 Which of the following program segments will sum the eight numbers input by the user? \text { Which of the following program segments will sum the eight numbers input by the user? }

A)For k As Integer = 1 To 8
s = CDbl(InputBox("Enter a number.")
S += k
Next
B) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
S += 1
Next
C) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
A += s
Next
D) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
S += a
Next
سؤال
What does the following program do with a person's name?
Private Sub btnDisplay click(...) Handles btnDisplay.click
Dim name, test As String
Dim n As String = ""
name = InputBox ("Enter your first name:")
For i As Integer =0= 0 To (name. Length - 1) Step 2
test == name. Substring (i,1)( i , 1 )
n=\mathrm { n } = test &n\& \mathrm { n }
Next
txtBox. Text =n= n
End Sab

A) in reverse order.
B) in reverse order and skips every other letter.
C) as it was entered.
D) as it was entered, but skips every other letter.
سؤال
What is one drawback in using non-integer Step sizes?

A) Round-off errors may cause unpredictable results.
B) Decimal Step sizes are invalid in Visual Basic.
C) A decimal Step size is never needed.
D) Decimal Step sizes usually produce infinite loops.
سؤال
How many lines of output are produced by the following program segment?
For i As Integer = 1 To 3
For j As Integer = 1 To 3
For k As Integer = i to j
lstBox.Items.Add("Programming is fun.")
Next
Next
Next

A) 8
B) 9
C) 10
D) 11
سؤال
When the odd numbers are added successively, any finite sum will be a perfect square (e.g., 1 + 3 + 5 = 9 and 9 = 3^2). What change must be made in the following program to correctly demonstrate this fact for the first few odd numbers? Private Sab btnDisplay_Click ()( \ldots ) Handles btnDisplay.Click
Dim oddNumber As Integer
Dim sum As Integer =0= 0
For i As Integer =1= 1 To 9 Step 2 \quad 'Generate first few odd numbers
oddNumber =i= \mathrm { i }
For j\mathrm { j } As Integer =1= 1 To oddNumber Step 2 \quad 'Add odd numbers
sum +=j+ = j
Next
lstBox.Iteins.Add (sum & " is a perfect square.")
Next
End Sub

A) Change the Step size to 1 in the first For statement.
B) Move oddNumber = i inside the second For loop.
C) Reset sum to zero immediately before the second Next statement.
D) Reset sum to zero immediately before the first Next statement.
سؤال
Assuming the following statement, what is the For...Next loop's counter variable?
For yr As Integer = 1 To 5

A) 1
B) 5
C) To
D) yr
سؤال
A Do…Loop Until block is always executed at least once.
سؤال
Which of the following loops will always be executed at least once when it is encountered?

A) a For...Next loop
B) a Do loop having posttest form
C) a Do loop having pretest form
D) none of the above.
سؤال
How many times will PETE be displayed when the following lines are executed?
For c As Integer = 15 to -4 Step -6
lstBox.Items.Add("PETE")
Next

A) 1
B) 2
C) 3
D) 4
سؤال
Suppose the days of the year are numbered from 1 to 365 and January 1 falls on a Tuesday as it did in 2013. What is the correct For statement to use if you want only the numbers for the Fridays in 2013?

A) For i As Integer = 3 to 365 Step 7
B) For i As Integer = 1 to 365 Step 3
C) For i As Integer = 365 To 1 Step -7
D) For i As Integer = 3 To 365 Step 6
سؤال
What will be displayed by the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim a As String, n, c As Integer
a = "HIGHBACK"
n = CInt(Int)
c = 0
For k As Integer = 0 To n - 1
If a.Substring(k, 1) > a.Substring(7 - k, 1) Then
c += 1
End If
Next
txtBox.Text = CStr(c)
End Sub

A) 1
B) 2
C) 3
D) 4
E) 5
سؤال
What will be displayed by the following program when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim s As Double
s = 0
For k As Integer = 1 To 5
If k / 2 = Int(k / 2) Then
s += k
End If
Next
txtBox.Text = CStr(s)
End Sub

A) 12
B) 9
C) 15
D) 6
سؤال
Which loop computes the sum of 1/2 + 2/3 + 3/4 + 4/5 + … + 99/100?

A) For n As Integer = 1 To 99
s += n / (1 + n)
Next
B) For q As Integer = 100 To 1
s += (q + 1) /q
Next
C) For d As Integer = 2 To 99
s = 1 / d + d / (d + 1)
Next
D) For x As Integer = 1 To 100
s += 1 / (x + 1)
Next
سؤال
What is the value of j after the end of the following code segment?
For j As Integer = 1 to 23
lstBox.Items.Add("The counter value is " & j)
Next

A) 22
B) 23
C) 24
D) j no longer exists
سؤال
A counter variable is normally incremented or decremented by 1.
سؤال
What will be displayed when the following lines are executed?
txtBox.Clear
For k As Integer = 1 To 3
txtBox.Text &= "ABCD".Substring(4 - k, 1)
Next

A) ABC
B) CBA
C) DBA
D) DCBA
E) DCB
سؤال
When the number of repetitions needed for a set of instructions is known before they are executed in a program, the best repetition structure to use is a(n)

A) Do While...Loop structure.
B) Do...Loop Until structure.
C) For...Next loop.
D) If blocks.
سؤال
If the counter variable of a For...Next loop will assume values that are not whole numbers, then the variable should not be of type Integer.
سؤال
The following lines of code display all the items of lstBox.
For n As Integer = 1 to lstBox.Items.Count lstBox2.Items.Add(lstBox.Items(n))
Next
سؤال
If one For...Next loop begins inside another For...Next loop, it must also end within this loop.
سؤال
The body of a For...Next loop in Visual Basic will always be executed once no matter what the initial and terminating values are.
سؤال
The step value of a For...Next loop can be given by a numeric literal, variable, or expression.
سؤال
The value of the counter variable in a For...Next loop need not be a whole number.
سؤال
What is the data type of the variable num if Option Infer is set to On and the statement Dim num = 7.0 is executed?

A) Integer
B) Boolean
C) Double
D) String
سؤال
When Option Infer is set to On, a statement of the form Dim num = 7 is valid.
سؤال
Which of the following expressions refers to the contents of the first row of the list box?

A) lstBox.Items(0)
B) lstBox.Items(1)
C) lstBox.Items.First
D) lstBox.Items(First)
سؤال
If the terminating value of a For...Next loop is less than the initial value, then the body of the loop is never executed.
سؤال
Which of the following expressions refers to the contents of the last row of the list box?
(A)lstBox.Items(lstBox.Items.Count)
B) lstBox.Items(lstBox.Items.Count - 1)
C) lstBox.Items(Count)
(D)lstBox.Items.Count
سؤال
One must always have a Next statement paired with a For statement.
سؤال
In a For...Next loop, the initial value should be greater than the terminating value if a negative step is used and the body of the loop is to be executed at least once.
سؤال
The variable index declared with the statement For index As Integer = 0 To 5 cannot be referred to outside of the For…Next loop.
سؤال
Each item in a list box is identified by an index number; the first item in the list is assigned which of the following values as an index?

A) a randomly assigned value
B) 1.
C) a value initially designated by the programmer
D) 0
سؤال
When one For...Next loop is contained within another, the name of the counter variable for each For...Next loop may be the same.
سؤال
The following code segment is valid.
If (firstLetter > "A") Then
For x As Integer = 1 to 100
lstBox.Items.Add(x)
Next
End If
سؤال
The value of the counter variable should not be altered within the body of a For…Next loop.
سؤال
If the initial value is greater than the terminating value in a For...Next loop, the statements within are still executed one time.
سؤال
A For...Next loop cannot be nested inside a Do loop.
سؤال
If a list box contains all numbers, then which of the following values can be calculated without using a loop?

A) average value of the numbers
B) largest number
C) smallest number
D) number of numbers
سؤال
If no item in a list box is selected, the value of lstBox.SelectedIndex is 0.
سؤال
Which of the following is not a main type of event that can be raised by user selections of items in a list box?

A) Click event
B) SelectedIndexChanged event
C) FillDown event
D) DoubleClick event
سؤال
A list box named lstBox has its Sorted property set to True and contains the three items Cat, Dog, and Gnu in its Items collection. If the word Elephant is added to the Items collection at run time, what will be its index value?

A) 2
B) 1
C) 3
D) 0
سؤال
If a program contains procedures for both the Click and DoubleClick events on a list box and the user double-clicks on the list box, only the Click event will be raised.
سؤال
A list box named lstBox has its Sorted property set to False and contains the three items Cat, Dog, and Gnu in its list. If the word Elephant is added to the list at run time, what will be its index value?

A) 2
B) 1
C) 3
D) 0
سؤال
The value of lstBox.Items(n) is the nth item in the list box.
سؤال
The ___________data type is most suited to a flag.

A) Boolean
B) Integer
C) String
D) Double
سؤال
If a list box has its sorted property set to True and the list box contains all numbers, then the values in the list box will always be in increasing numerical order.
سؤال
Which of the statements will unhighlight any highlighted item in lstBox?

A) lstBox.SelectedItem = Nothing
B) lstBox.SelectedItem = ""
C) lstBox.SelectedIndex = 0
D) lstBox.SelectedIndex = -1
سؤال
The sorted property can only be set to True at design time.
سؤال
The number of items in ListBox1 is ListBox1.Items.Count.
سؤال
A variable that keeps track of whether a certain situation has occurred is called___________

A) a counter.
B) an accumulator.
C) a switch.
D) a flag.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/73
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Repetition
1
_________calculate the number of elements in lists.

A) Sentinels
B) Counter variables
C) Accumulators
D) Nested loops
Counter variables
2
A variable declared inside a Do loop cannot be referred to outside of the loop.
True
3
What is wrong with the following simple password program where today's password is "intrepid"
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim password As String
password = InputBox ("Enter today's password:")
Do
lstBox. Items. Add ("Incorrect")
password = InputBox ("Enter today's password:")
Loop Until password = "intrepid"
lstBox. Items. Add ("Password Correct. You may continue.")
End Sub

A) There is no way to re-enter a failed password.
B) The Loop Until condition should be passWord <> "intrepid".
C) It will display "Incorrect." even if the first response is "intrepid".
D) Nothing
It will display "Incorrect." even if the first response is "intrepid".
4
A loop written using the structure Do While...Loop can usually be rewritten using the structure Do...Loop Until.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
5
What numbers will be displayed in the list box by the following code when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer = 7
Do
num += 1
lstBox.Items.Add(num)
Loop Until (num > 6)
lstBox.Items.Add(num)
End Sub

A) 7
B) 8
C) 7 and 8
D) 8 and 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
6
If the loop is to be executed at least once, the condition should be checked at the__________ .

A) top of the loop
B) middle of the loop
C) bottom of the loop
D) Nothing should be checked.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
7
The following statement is valid.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
8
How many times will HI be displayed when the following lines are executed?
Dim c As Integer = 12
Do
lstBox.Items.Add("HI")
c += 3
Loop Until (c >= 30)

A) 5
B) 9
C) 6
D) 4
E) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
9
In the following code segment, what type of variable is counter?
Dim temp, counter, check As Integer
Do
temp = CInt(InputBox("Enter a number."))
counter += temp
If counter = 10 Then
check = 0
End If
Loop Until (check = 0)

A) counter
B) accumulator
C) sentinel
D) loop control variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
10
In analyzing the solution to a program, you conclude that you want to construct a loop so that the loop terminates either when (a < 12) or when (b = 16). Using a Do loop, the test condition should be

A) Do While (a > 12) Or (b <> 16)
B) Do While (a >= 12) Or (b <> 16)
C) Do While (a < 12) Or (b <> 16)
D) Do While (a >= 12) And (b <> 16)
E) Do While (a < 12) And (b = 16)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
11
_________calculate the sums of numerical values in lists.

A) Sentinels
B) Counter variables
C) Accumulator variables
D) Nested loops
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
12
When Visual Basic executes a Do While loop it first checks the truth value of the__________ .

A) pass
B) loop
C) condition
D) statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
13
The following two sets of code produce the same output.
5 )\end{array}"> Dim num As Integer =1 Dim num As Integer =1 Do While nam <=5 Do  lstBox.Items.Add ("Hello")  lstBox. Items. Add ("Hello")  num +=1 num +=1 Loop  Loop Until (nam >5)\begin{array} { l l } \text { Dim num As Integer } = 1 & \text { Dim num As Integer } = 1 \\\text { Do While nam } < = 5 & \text { Do } \\\text { lstBox.Items.Add ("Hello") } & \text { lstBox. Items. Add ("Hello") } \\\text { num } + = 1 & \text { num } + = 1 \\\text { Loop } & \text { Loop Until (nam } > 5 )\end{array}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
14
The following are equivalent While and Until statements.
While (num > 2) And (num < 5)
Until (num <= 2) Or (num >= 5)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
15
What numbers will be displayed in the list box when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim num as Double = 10 Do While num > 1 lstBox.Items.Add(num) num = num - 3 Loop End Sub

A) 10, 7, and 4
B) 10, 7, 4, and 1
C) 10, 7, 4, 1, and -2
D) No output
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
16
A Do While loop checks the While condition before executing the statements in the loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
17
If the While condition in a Do While loop is false the first time it is encountered, the statements in the loop are still executed once.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which While statement is equivalent to Until num < 100?

A) While num <= 100
B) While num > 100
C) While num >= 100
D) There is no equivalent While statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
19
What is wrong with the following Do loop? Dim index As Integer = 1 Do While index <> 10 lstBox.Items.Add("Hello") index += 2 Loop

A) It should have been written as a Do Until loop.
B) It is an infinite loop.
C) The test variable should not be changed within the loop itself.
D) Nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
20
What is wrong with the following Do loop? Dim index As Integer = 1 Do While index <> 9 lstBox.Items.Add("Hello") index += 1 Loop

A) The test variable should not be changed inside a Do loop.
B) The test condition will never be true.
C) This is an infinite loop.
D) Nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following are valid for an initial or terminating value of a Fir...Next loop?

A) a numeric literal
B) info.Length, where info is a string variable
C) a numeric expression
D) All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
22
In a For statement of the form shown below, what is the default step value when the "Step c" clause is omitted?
For i As Integer = a To b Step c

A) the same as a
B) the same as b
C) 0
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
23
A For...Next loop with a positive step value continues to execute until what condition is met?

A) The counter variable is greater than the terminating value.
B) The counter variable is equal to or greater than the terminating value.
C) The counter variable is less than the terminating value.
D) The counter variable is less than or equal to the terminating value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
24
 Which of the following program segments will sum the eight numbers input by the user? \text { Which of the following program segments will sum the eight numbers input by the user? }

A)For k As Integer = 1 To 8
s = CDbl(InputBox("Enter a number.")
S += k
Next
B) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
S += 1
Next
C) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
A += s
Next
D) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
S += a
Next
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
25
What does the following program do with a person's name?
Private Sub btnDisplay click(...) Handles btnDisplay.click
Dim name, test As String
Dim n As String = ""
name = InputBox ("Enter your first name:")
For i As Integer =0= 0 To (name. Length - 1) Step 2
test == name. Substring (i,1)( i , 1 )
n=\mathrm { n } = test &n\& \mathrm { n }
Next
txtBox. Text =n= n
End Sab

A) in reverse order.
B) in reverse order and skips every other letter.
C) as it was entered.
D) as it was entered, but skips every other letter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is one drawback in using non-integer Step sizes?

A) Round-off errors may cause unpredictable results.
B) Decimal Step sizes are invalid in Visual Basic.
C) A decimal Step size is never needed.
D) Decimal Step sizes usually produce infinite loops.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
27
How many lines of output are produced by the following program segment?
For i As Integer = 1 To 3
For j As Integer = 1 To 3
For k As Integer = i to j
lstBox.Items.Add("Programming is fun.")
Next
Next
Next

A) 8
B) 9
C) 10
D) 11
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
28
When the odd numbers are added successively, any finite sum will be a perfect square (e.g., 1 + 3 + 5 = 9 and 9 = 3^2). What change must be made in the following program to correctly demonstrate this fact for the first few odd numbers? Private Sab btnDisplay_Click ()( \ldots ) Handles btnDisplay.Click
Dim oddNumber As Integer
Dim sum As Integer =0= 0
For i As Integer =1= 1 To 9 Step 2 \quad 'Generate first few odd numbers
oddNumber =i= \mathrm { i }
For j\mathrm { j } As Integer =1= 1 To oddNumber Step 2 \quad 'Add odd numbers
sum +=j+ = j
Next
lstBox.Iteins.Add (sum & " is a perfect square.")
Next
End Sub

A) Change the Step size to 1 in the first For statement.
B) Move oddNumber = i inside the second For loop.
C) Reset sum to zero immediately before the second Next statement.
D) Reset sum to zero immediately before the first Next statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
29
Assuming the following statement, what is the For...Next loop's counter variable?
For yr As Integer = 1 To 5

A) 1
B) 5
C) To
D) yr
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
30
A Do…Loop Until block is always executed at least once.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which of the following loops will always be executed at least once when it is encountered?

A) a For...Next loop
B) a Do loop having posttest form
C) a Do loop having pretest form
D) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
32
How many times will PETE be displayed when the following lines are executed?
For c As Integer = 15 to -4 Step -6
lstBox.Items.Add("PETE")
Next

A) 1
B) 2
C) 3
D) 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
33
Suppose the days of the year are numbered from 1 to 365 and January 1 falls on a Tuesday as it did in 2013. What is the correct For statement to use if you want only the numbers for the Fridays in 2013?

A) For i As Integer = 3 to 365 Step 7
B) For i As Integer = 1 to 365 Step 3
C) For i As Integer = 365 To 1 Step -7
D) For i As Integer = 3 To 365 Step 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
34
What will be displayed by the following program when the button is clicked? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim a As String, n, c As Integer
a = "HIGHBACK"
n = CInt(Int)
c = 0
For k As Integer = 0 To n - 1
If a.Substring(k, 1) > a.Substring(7 - k, 1) Then
c += 1
End If
Next
txtBox.Text = CStr(c)
End Sub

A) 1
B) 2
C) 3
D) 4
E) 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
35
What will be displayed by the following program when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim s As Double
s = 0
For k As Integer = 1 To 5
If k / 2 = Int(k / 2) Then
s += k
End If
Next
txtBox.Text = CStr(s)
End Sub

A) 12
B) 9
C) 15
D) 6
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which loop computes the sum of 1/2 + 2/3 + 3/4 + 4/5 + … + 99/100?

A) For n As Integer = 1 To 99
s += n / (1 + n)
Next
B) For q As Integer = 100 To 1
s += (q + 1) /q
Next
C) For d As Integer = 2 To 99
s = 1 / d + d / (d + 1)
Next
D) For x As Integer = 1 To 100
s += 1 / (x + 1)
Next
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
37
What is the value of j after the end of the following code segment?
For j As Integer = 1 to 23
lstBox.Items.Add("The counter value is " & j)
Next

A) 22
B) 23
C) 24
D) j no longer exists
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
38
A counter variable is normally incremented or decremented by 1.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
39
What will be displayed when the following lines are executed?
txtBox.Clear
For k As Integer = 1 To 3
txtBox.Text &= "ABCD".Substring(4 - k, 1)
Next

A) ABC
B) CBA
C) DBA
D) DCBA
E) DCB
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
40
When the number of repetitions needed for a set of instructions is known before they are executed in a program, the best repetition structure to use is a(n)

A) Do While...Loop structure.
B) Do...Loop Until structure.
C) For...Next loop.
D) If blocks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
41
If the counter variable of a For...Next loop will assume values that are not whole numbers, then the variable should not be of type Integer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
42
The following lines of code display all the items of lstBox.
For n As Integer = 1 to lstBox.Items.Count lstBox2.Items.Add(lstBox.Items(n))
Next
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
43
If one For...Next loop begins inside another For...Next loop, it must also end within this loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
44
The body of a For...Next loop in Visual Basic will always be executed once no matter what the initial and terminating values are.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
45
The step value of a For...Next loop can be given by a numeric literal, variable, or expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
46
The value of the counter variable in a For...Next loop need not be a whole number.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
47
What is the data type of the variable num if Option Infer is set to On and the statement Dim num = 7.0 is executed?

A) Integer
B) Boolean
C) Double
D) String
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
48
When Option Infer is set to On, a statement of the form Dim num = 7 is valid.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
49
Which of the following expressions refers to the contents of the first row of the list box?

A) lstBox.Items(0)
B) lstBox.Items(1)
C) lstBox.Items.First
D) lstBox.Items(First)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
50
If the terminating value of a For...Next loop is less than the initial value, then the body of the loop is never executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
51
Which of the following expressions refers to the contents of the last row of the list box?
(A)lstBox.Items(lstBox.Items.Count)
B) lstBox.Items(lstBox.Items.Count - 1)
C) lstBox.Items(Count)
(D)lstBox.Items.Count
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
52
One must always have a Next statement paired with a For statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
53
In a For...Next loop, the initial value should be greater than the terminating value if a negative step is used and the body of the loop is to be executed at least once.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
54
The variable index declared with the statement For index As Integer = 0 To 5 cannot be referred to outside of the For…Next loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
55
Each item in a list box is identified by an index number; the first item in the list is assigned which of the following values as an index?

A) a randomly assigned value
B) 1.
C) a value initially designated by the programmer
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
56
When one For...Next loop is contained within another, the name of the counter variable for each For...Next loop may be the same.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
57
The following code segment is valid.
If (firstLetter > "A") Then
For x As Integer = 1 to 100
lstBox.Items.Add(x)
Next
End If
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
58
The value of the counter variable should not be altered within the body of a For…Next loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
59
If the initial value is greater than the terminating value in a For...Next loop, the statements within are still executed one time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
60
A For...Next loop cannot be nested inside a Do loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
61
If a list box contains all numbers, then which of the following values can be calculated without using a loop?

A) average value of the numbers
B) largest number
C) smallest number
D) number of numbers
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
62
If no item in a list box is selected, the value of lstBox.SelectedIndex is 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
63
Which of the following is not a main type of event that can be raised by user selections of items in a list box?

A) Click event
B) SelectedIndexChanged event
C) FillDown event
D) DoubleClick event
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
64
A list box named lstBox has its Sorted property set to True and contains the three items Cat, Dog, and Gnu in its Items collection. If the word Elephant is added to the Items collection at run time, what will be its index value?

A) 2
B) 1
C) 3
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
65
If a program contains procedures for both the Click and DoubleClick events on a list box and the user double-clicks on the list box, only the Click event will be raised.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
66
A list box named lstBox has its Sorted property set to False and contains the three items Cat, Dog, and Gnu in its list. If the word Elephant is added to the list at run time, what will be its index value?

A) 2
B) 1
C) 3
D) 0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
67
The value of lstBox.Items(n) is the nth item in the list box.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
68
The ___________data type is most suited to a flag.

A) Boolean
B) Integer
C) String
D) Double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
69
If a list box has its sorted property set to True and the list box contains all numbers, then the values in the list box will always be in increasing numerical order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
70
Which of the statements will unhighlight any highlighted item in lstBox?

A) lstBox.SelectedItem = Nothing
B) lstBox.SelectedItem = ""
C) lstBox.SelectedIndex = 0
D) lstBox.SelectedIndex = -1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
71
The sorted property can only be set to True at design time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
72
The number of items in ListBox1 is ListBox1.Items.Count.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
73
A variable that keeps track of whether a certain situation has occurred is called___________

A) a counter.
B) an accumulator.
C) a switch.
D) a flag.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 73 في هذه المجموعة.