Suppose you have "n" integer numbers and you need to calculate average of that "n" numbers then it is not necessary that you always get an integer value as average so at that situation you need to typecast the result in float. for example let n=4
and the number is 2, 3, 8, 5 now if you find the average then you get (2+3+8+5)/4 i.e. average will be 18/4=4.5 but as you have taken integer numbers so you will get result as 4 but not 4.5 so you need to typecast the result of average in float so that you will get average as 4.5.
Get Answers For Free
Most questions answered within 1 hours.