Question: Function getMinimumInt ( integer array ( 5 ) userVals ) returns integer minInt / / Modified Error 1 : Pass the array value with size

Function getMinimumInt(integer array(5) userVals) returns integer minInt
// Modified Error 1: Pass the array value with size of
integer i
minInt = userVals[5]
// Iterating the array and finding the min of the array
// Modified Error 2: Iterate the loop from zero rather
for i =0; i < userVals.size; i = i +1
if userVals[i]< minInt
minInt = userVals[i]
Function Main() returns nothing
// integer array
integer array(5) userVals
// taking user input and storing it the array
integer i
// Modified Error 3: Declare the variable here rat
// than below the getting an error on Line 15:
// Variable declaration must be at top of function.
integer min
for i =0; i < userVals.size; i = i +1
userVals[i]= Get next input
// Don't declare integer min here
min = getMinimumInt(userVals)
// normalizing the array
for i =0; i < userVals.size; i = i +1
userVals[i]= userVals[i]- min
//printing the output
Put userVals[i] to output
Put "" to output (this is the code I used , however I am getting the error message "An array index of 5 is too large; valid range of userVals: 0-4" how would I correct this? I followed the above example verbatim

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!