#include <stdio.h>
#include <stdlib.h>
int main (void)
{
double f;
printf ("What is the temperature in Fahrenheit?\n");
scanf ("%d", &f);
double x = (f-32)*(5/9);
printf ("%d degrees Fahrenheit \n",f);
printf ("%d degrees Celsius",x);
system("PAUSE");
return 0;
}
The code seems to be printing the address of variable f instead of the value; it’s probably a syntax mistake.
In the
printf()calls,%dshould be%f(or perhaps%.2f):You also need to change:
to
In C, integer division (a division where both dividend and divisor are integer types) truncates, so 5/9 is always 0.
Also, the conversion specification for
doublewithscanf()is%lf: