# Understanding the return

**URL:** <https://discourse.processing.org/t/understanding-the-return/4274>\
**Category:** Beginners\
**Created:** [October 9, 2018, 12:51pm UTC](https://discourse.processing.org/t/understanding-the-return/4274 "2018-10-09T12:51:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![losferatos](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@losferatos](https://discourse.processing.org/u/losferatos)\
**Post date:** [October 9, 2018, 12:51pm UTC](https://discourse.processing.org/t/understanding-the-return/4274/1 "2018-10-09T12:51:43Z")

</div>

Hi guys!

I’m just playing around processing to learn and understand it.  
But I stumbled upon a really basic problem: Where does the return function return to?

After the function has done their job it should return the value, because I wanna save it to calculate an average, or whatever.

```auto
int var;

void setup() {
}

void draw() {
  for (int i=1; i<=10; i++) {
    tues(i);
    if ( i>=10) {
      noLoop();
    }
  }

}
int tues(int a) {
  int quad = a*a;
  println(a + "² = " + quad);
  return quad;
}

```

AFAIK the value of quad gets returned to where the function was called (so I guess it must be inside the loop, right?). But when I try to get the value of quad it always says that there is no variable available.

So where does the value gets returned to?

Thanks in advance =)  
Eric

---

<div class="post-metadata">

**Author:** ![Dennis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dennis/32/1111_2.png) [@Dennis](https://discourse.processing.org/u/Dennis)\
**Post date:** [October 9, 2018, 1:22pm UTC](https://discourse.processing.org/t/understanding-the-return/4274/2 "2018-10-09T13:22:24Z")

</div>

Hi losferatos, you must save the returned tues(i) value in a variable.  
you have correctly instantiated a variable var but did not use it.

```auto
int var;

void setup() {
}

void draw() {
  for (int i=1; i<=10; i++) {
    var = tues(i); // tues return a value and is assigned in a variable var
    println("variable 'var' = " + var);
    if ( i>=10) {
      noLoop();
    }
  }

}
int tues(int a) {
  int quad = a*a;
  println(a + "² = " + quad);
  return quad;
}

```

was this what you intended to do?
