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

Why am I getting an error?? Please help Homework 16- Find the Minimum -Problem D

ID: 3595617 • Letter: W

Question

Why am I getting an error?? Please help

Homework 16- Find the Minimum -Problem Description This problem will give you practice using arrays as function parameters. -Instruction The following code has been written for you #include iostream» using namespace std; const int SIZE 5; Instruction Prototype a function named GetMin that returns an integer (the index of the minimum value in the array) and takes an integer array of size SIZE. You dont have to pass the size for this problem as it is global. See Answer Grade This Part Correct-You have completed this portion of the problem. You earned 5 out of a possible 5 points results Instructor Output Input cmd line arg Minimum is index 3 which is value 1Minimum is index 3 which is value1 stdin 4 cmd line arg Minimum is index 4 which is value -5 Minimum is index 4 which is value -5 stdin -1 -2 -3 -4

Explanation / Answer

You are getting wrong answer because while calculating minIndex in function you are not updating the value of minVal.

minVal takes arr[0] which is 5 since 4 is less than 5 therefore it will consider it as min because 4 is in the last iteration. For correct answer, in if block, add the following statement in if block:

minVal = arr[i];

Hope it helps, do give your valuable response.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote