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 Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim oddNumber As Integer
Dim sum As Integer = 0
For i As Integer = 1 To 9 Step 2 'Generate first few odd numbers
oddNumber = i
For j As Integer = 1 To oddNumber Step 2 'Add odd numbers
sum += j
Next
lstBox.Items.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.


(C) Reset sum to zero immediately before the second Next statement.

Computer Science & Information Technology

You might also like to view...

What is a string?

What will be an ideal response?

Computer Science & Information Technology

Tables are displayed without borders by default.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Among the following, which is the best protection against ransomware?

Windows File History Carbonite Keylogger software Authy by Twilio

Computer Science & Information Technology

The ____________________ program can be used to list services covered by xinetd or to turn services on and off.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology