Your while loop statement is misplaced. It should be placed before the first printf().
As PIEBALDConsult pointed out, you need to have a break condition, because otherwise your loop will run forever.
int main(void)
{
int v, t, wc;
while (1)
{
printf("Enter temp = 100 to exit.\n\n");
printf("Input temperature (<= 40° F) :...\n");
scanf_s("%d", &t);
if (t == 100)
break;
printf("Input wind speed (>= 6 mph) :...\n");
scanf_s("%d", &v);
if (t <= 40 && v >= 6)
{
wc = (int)(0.0817*(3.71*sqrt(v) + 5.81 - 0.25*v)*(t - 91.4) + 91.4);
printf("The wind chill is %d degrees F.\n", wc);
}
else
{
printf("Number is out of range. Try again");
}
}
return 0;
}
As for rounding up, use the function
ceil()
in
math.h
For rounding down use
floor()
.
Only casting to an int will truncate the value, hence 1.1 becomes 1.
For proper rounding you need to check if the value is smaller or larger than .5 and chose between ceil() and floor().