# Tutorial 48 Problems

 dan mendez · May 24, 2015 I noticed that in tutorial 48 I was getting the incorrect average when I wrote the code. This happened when I was using typecast to change the integers to floats. When I set "howMany" and "total" to floats in the beginning, I was able to get the correct average. Does anyone know why this is?

## Replies

 dan mendez · May 24, 2015 Thank you for the explanation! Makes sense now! Laura Lee · May 24, 2015 I declared f twice by accident. Apologies for that. Laura Lee · May 24, 2015 I have not seen the video but I'll assume what you're asking is why an integer gives an incorrect value?The answer is simple. Integer as is stated by definition is a whole value. It is a rational of course, over 1.The same rules apply here.``float f = 3;int n = 3;printf("%i\n",n/2);// 3/2 is 1.5, but n is an integer. Instead, 1 will be printed.float f = 3;printf("%f\n",f/2);//Will print 1.5``When performing averages, you might end up with results that are not whole numbers.
• 1

## C

129,905 followers