Possible Duplicate:
Why can’t decimal numbers be represented exactly in binary?
#include <stdio.h>
int main(void)
{
int temperature, time;
float minutes;
printf("What is the Fahrenheit temperature?\n");
scanf("%d",&temperature);
time = (5 - (temperature - 90) / 5);
minutes = ((5 % time) * 60);
if (temperature >= 90)
printf("It will rain at approximately %d hours and %f minutes after noon.\n", time, minutes);
else
printf("It will not rain today.\n");
system("PAUSE");
return 0;
}
I am using the C programming language. This is homework but its okay to use some bits from the web as long as its not the whole code. Anyways, If the current temperature is 93f time = 4.4
so I would like to output:
It will rain approximately 4 hours and 24 minutes after noon
but the output instead is:
It will rain at approximately 5 hours and 0.000000 minutes after noon
EDIT: I get an error now that states invalid operands to binary % (have int and float) Please be patient with me LOL I am trying to learn.
#include <stdio.h>
int main(void)
{
int current_temp;
float remaining_minutes, time;
printf("What is the temperature in Fahrenheit?\n");
scanf("%d",¤t_temp);
time = (5 - (current_temp - 90) / 5);
ERROR**** remaining_minutes = ((5 % time) * 60);
if (current_temp >= 90)
printf("It will rain at approximately %d hours and %f minutes after noon.\n", time);
else
printf("It will not rain today.\n");
system("PAUSE");
return 0;
}