Write a program which has a global array of
integers with values assigned to the array.
• Write a function ‘getArrayMin’ to return the
minimum value in the array.
• Draw a circle in the centre of the window with
the greyscale colour returned by the
int getMin(int x,int y)
Not yet correct…
- the way you call the function getMin() must match
- the way you defined the function.
(or vice versa)
You need to pass an array to it, so the way you call the function getMin is actually correct (you call it here:
But the header of the function doesn’t match it (where you define the function).
Definition of the function is now
int getMin(int x,int y) but it should be
int getMin(int arrMy)
What you have to do in the function
You need to for-loop over the array “arrMy” in the function, so you look at each item in the array.
You can store how small the smallest number is in the variable smallestMy (initially set it very high)
When the next number is smaller than your smallest number up to now, set smallestMy again to the current number