When the following code is executed, the loop does not run when f == 2.0
Why wouldn't it?
last line of output from program:Code:int main()
{
printf("\n\n\n"); //spacer
float f = .1;
while (f <= 2.0)
{
printf("%.1f*Pi: sin() = %f cos() = %f tan() = %f\n",
f,
sin(PI*f),
cos(PI*f),
tan(PI*f));
f += .1;
printf("\nf now equals %f",f);
}
printf("\n\n\n"); //spacer
return 0;
}
I also tried to see if this statement returned a true value:Code:1.9*Pi: sin() = -0.309016 cos() = 0.951057 tan() = -0.324919
f now equals 2.000000
..and it did, so I have no idea why my loop only runs until f == 1.9Code:(2.0 == 2.00)
I know I could eliminate the problem by changing my loop to:
But i'm curious as to why it isn't working as is.Code:while (f < 2.1)
Thank you for any help.