# I have an assignment to do but its kind of confusing and I want to know if what I did is correct (get Minimum)

**URL:** https://discourse.processing.org/t/i-have-an-assignment-to-do-but-its-kind-of-confusing-and-i-want-to-know-if-what-i-did-is-correct-get-minimum/26140
**Category:** Coding Questions
**Tags:** homework
**Created:** [December 11, 2020, 5:23pm UTC](https://discourse.processing.org/t/i-have-an-assignment-to-do-but-its-kind-of-confusing-and-i-want-to-know-if-what-i-did-is-correct-get-minimum/26140 "2020-12-11T17:23:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![DijaAngel](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DijaAngel](https://discourse.processing.org/u/DijaAngel)
#### Post date: [December 11, 2020, 5:23pm UTC](https://discourse.processing.org/t/i-have-an-assignment-to-do-but-its-kind-of-confusing-and-i-want-to-know-if-what-i-did-is-correct-get-minimum/26140/1 "2020-12-11T17:23:58Z")

</div>

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  
getArrayMin function

```auto
 int myArray[]={25,5,24,6,45,4};
void setup(){
}
void draw(){
  println("Smallest",getMin(myArray));
}
int getMin(int x,int y)
{
  int hold=x;
  if(y<x)
  {
    hold=y;
  }
  return hold;
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [December 11, 2020, 6:14pm UTC](https://discourse.processing.org/t/i-have-an-assignment-to-do-but-its-kind-of-confusing-and-i-want-to-know-if-what-i-did-is-correct-get-minimum/26140/2 "2020-12-11T18:14:47Z")

</div>

Not yet correct…

First,

- 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: ` println("Smallest",getMin(myArray));`, specifically `getMin(myArray)`).

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

return smallestMy
