The amount of data you collect before averaging is pretty much a personal prference. If the value does not swing much then more is a waist of time. Large swings withe the most being mid range then you need to collectet enough to cover it all.

To do he averaging. Set up a loop reading the ADC for the amount you want to collect. Keep adding the VAR to it's self then divide when finished.