If we want to average a set of numbers, we add them together, then divide by the number in the set.

150 + 200 + 0 = 350 / 3 = 116 Average

I’m using int and dropping the fractional parts. Use float if you need them.

But if we want the Median, which is the center, or middle number, we have to sort and compare each number to the others to get a list from high to low, and grab the center number. In this case, the Median is 150.

I’ve written a sketch that calculates both so you can compare your own numbers, and make it a much larger list:

### Become the Maker you were born to be. Try Arduino Academy for FREE!

int a[] = {150,200,0};

int n = 3;

a[] is your set of values

n is the number of values in the set

More info on Mean, Median & Average – https://www.vocabulary.com/articles/chooseyourwords/mean-median-average/