Data type cast: from int to float : Data Type Cast « Data Type « C Tutorial






#include <stdio.h>

int main(void)
{
  int count = 110;                      
  long sum = 10L;                       
  float average = 0.0f;                


  average = (float)sum/count;          

  printf("\nAverage of the ten numbers entered is: %f\n", average);
  return 0;
}
Average of the ten numbers entered is: 0.090909








2.31.Data Type Cast
2.31.1.Type conversion
2.31.2.Forced conversion
2.31.3.Type casting
2.31.4.Data type cast: from int to float