Hello. I have a function that averages 3 values and knows how to do it depending on which values are greater than zero:

```
int8_t average(int8_t near, int8_t far, int8_t out) { //returns avg temp and knows how to avg temps depending on which sensors are plugged in.
if (near < 0 && far < 0 && out < 0) { //if none are plugged in, return zero.
return 0;
} //end if.
else if (near < 0 && far < 0) { //if two of the 3 are unplugged, return the one that isnt.
return out;
} //end else.
else if (far < 0 && out < 0) {
return near;
} //end else.
else if (near < 0 && out < 0) {
return far;
} //end else.
else if (near < 0) { //if one is unplugged, return avg of other two.
return (far + out) / 2;
} //end else.
else if (far < 0) {
return (near + out) / 2;
} //end else.
else if (out < 0) {
return (near + far) / 2;
} //end else.
else { //return avg of all 3.
return (near + far + out) / 3;
} //end else.
} //end average().
```

It seems like its doing the same tests over and over and probably redundantly. Any ideas on how to streamline it?

Thanks!