A mean from alternate readings

A Visual Basic .NET program selects every second reading from a force sensor, beginning with the first array element. The following statements execute inside Sub Main:


Visual Basic
Dim forcesN() As Double = {2.4, 3.1, 2.8, 3.7, 3.0}
Dim totalN As Double = 0.0
Dim selectedCount As Integer = 0

For i As Integer = 0 To forcesN.Length - 1 Step 2
    totalN += forcesN(i)
    selectedCount += 1
Next

Dim meanN As Double = totalN / selectedCount


What value is stored in meanN? Give your answer in newtons, to two decimal places.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Visual Basic Questions: