int main()
{
float a,
a = 2.0e20;
printf(“%f”,a);
}
Here looking at the program we expect that the output should be like 200..( 0 for 20 times).
but to our astonishment we are getting the output as 200000004008175468544.
Can anyone please tell me the reason behind such an output.?
2.0e20 is out of range for float, thus you are getting such an output. Infact, any this > e10 in float will give an unexpected output. Try it with double, it’ll work.
float work anly on 6 decimals so thats why it gives u wrong ans