So, I am a beginner in C programming and I encountered a problem while doing a particular mathematical operation using float data type in C. .
float i=(501.0/10.0);
when I print "i" without making any modifications it doesn't return a value = 50.1 but something like 50.099... but when I try to print the value as : printf("%0.2f",i); it returns the value as 50.10 Why am I encountering this problem and is it intended behaviour? If yes, please explain