I need to return a value float with 1 decimal place, however it is returning with the value rounded.
I have the following code:
float n1 = 4;
float n2 = 9;
float total = n2 / n1 ;
printf("Media: %.1f ", total ); //aqui, o resultado é 2.3
printf("Media: %.2f", total); //aqui, o resultado é 2.25
The expected value should be Média = 2.2
, but it is returning 2.3
.
Is there a solution?