i started learning c
. Today, while i am working on a program, i found an interesting thing and i made another small program (similar to my issue) to check it.
#include<stdio.h>
int main(void)
{
float num1=867.0;
float num2=.6921;
printf("sum = %.4f \n",num1+num2);
return 0;
}
if i run the above program, i am getting 867.6921
as the answer. but if i changed the .4%f
to %f
the answer is changing to sum = 867.692078
. why's the change in the output? Also, is there any way that i can get the answer without using the .4%f
?