There must be some logic behind this calculation. But I am not able to get it. The normal mathematics does not result in such behavior. Can anyone help me out in explaining why
printf ("float %f \n", 2/7 * 100.0); results in printing 1.000000
Why so? I am not understanding the reason
Integer division.
2/7 = 0as an integer,0 * 100.0 = 0.0as a float.Do
2.0/7 * 100.0to get the answer you’re looking for.