Write a program that displays the table of Fahrenheit - Celsius temperatures.
Below is my code, the problem with it is that the celsius column is all zeros,please correct my mistake, thank you:
#include "stdafx.h"
#include "genlib.h"
#include "simpio.h"
#include "math.h"
int _tmain(int argc, _TCHAR* argv[])
{
int i;
double c;
printf("Fahrenheit Celsius\n");
for (i=0;i<=0;i+=20)
{
c=(5/9)*(i-32);
printf("%d %f\n",i,c);
}
for (i=20;i<=80;i+=20)
{
c=(5/9)*(i-32);
printf("%d %f\n",i,c);
}
for (i=100;i<=200;i+=20)
{
c=(5/9)*(i-32);
printf("%d %f\n",i,c);
}
}
-------------------------------------------------------------------------------------
I tried using %g instead of %f, but it's still all zeros.
-------------------------------------------------------------------------------------
The output should appear as follows:
Fahrenheit Celsius
0 -17.8
20 -6.7
40 4.4
60 15.6
80 26.7
100 37.8
120 48.9
140 60.0
160 71.1
180 82.2
200 93.3
Press any key to continue_
--------------------------------------------------------------------
The output that my program has:
Fahrenheit Celsius
0 0
20 0
40 0
60 0
80 0
100 0
120 0
140 0
160 0
180 0
200 0
Press any key to continue_
-------------------------------------------------------------------------------------
I tried using %g instead of %f, but it's still all zeros.
the problem with it is that the celsius column is all zeros,please correct my mistake, thank you