Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following correctly displays the lowest value in myArray? Constant

ID: 3761633 • Letter: W

Question

Which of the following correctly displays the lowest value in myArray?

Constant Integer SIZE= 30

Declare Integer index

Declare Real lowValue

Declare Real myArray[SIZE]

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] < lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

Set lowValue = myArray[0]

For index = lowValue To SIZE

    If myArray[index] < lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] >= lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] > lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

a.

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] < lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

b.

Set lowValue = myArray[0]

For index = lowValue To SIZE

    If myArray[index] < lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

c.

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] >= lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

d.

Set lowValue = myArray[0]

For index = 1 To SIZE-1

    If myArray[index] > lowValue Then

         Set lowValue = myArray[index]

    End If

End For

Display lowValue

Explanation / Answer

a is the answer.

The logic goes like this.

1. Initially assume the first value in the array myArray[0] as lowvalue.

2. Then starting from the second value till the last value, compare every value in the array to the lowvalue, which we assumed. If any of the array is lower than the lowvalue(we will update our assumption), assign the new array value to lowvalue.

3. By the time you reach the end of array, the lowvalue will hold the lowest value.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote