#include <stdio.h>
//function prototypes
const double fiveNinths = 5 / 9;
int toCelsius(double value)
{
return ((value - 32) * (fiveNinths));
}
int toFarenheit(double value)
{
return (value * 1.8) + 32;
}
int main (void)
{
int intValue, menuSelect;
double results;
intValue = 1;
while (intValue > 0)
{
printf( "enter a positive integer: \n");
scanf("%d", &intValue);
if (intValue > 0)
{
printf("Enter 1 to convert to Farenheit, enter 2 to convert to Celsius: \n");
scanf("%d", &menuSelect);
if (menuSelect == 1)
{
results = toFarenheit(intValue);
printf("%d degrees to Farenheit is %d\n", intValue, results);
}
else if (menuSelect == 2)
{
results = toCelsius(intValue);
printf("%d degrees to Celsius is %d\n", intValue, results);
}
else
{
printf("invalid menu item, please input only 1 or 2\n");
}
}
}
return 0;
}
I can't figure out why my toCelsius value always returns 0. my toFarenheit function works just fine. Also, this program terminates by having the user enter in a negative integer value; it's part of the homework assignment so disregard that part.