Fahrenheit to Celsius Table
Fahrenheit to Celsius Table
Send Feedback
Fahrenheit to Celsius Table
3 integers - S, E and W respectively
Fahrenheit to Celsius conversion table. One line for every Fahrenheit and Celsius Fahrenheit value. Fahrenheit value and its corresponding Celsius value should be separate by tab ("\t")
0 <= S <= 1000
0 <= E <= 1000
0 <= W <= 1000
0
100
20
0 -17
20 -6
40 4
60 15
80 26
100 37
120
200
40
120 48
160 71
200 93
Start value is 120, end value is 200 and step size is 40. Therefore, the values we need to convert are 120, 120 + 40 = 160, and 160 + 40 = 200.
The formula for converting Fahrenheit to Celsius is:
Celsius Value = (5/9)*(Fahrenheit Value - 32)
Plugging 120 into the formula, the celsius value will be (5 / 9)*(120 - 32) => (5 / 9) * 88 => (5 * 88) / 9 => 440 / 9 => 48.88
But we'll only print 48 because we are only interested in the integral part of the value.
void printTable(int start, int end, int step) { /* Don't write main(). * Don't read input, it is passed as function argument. * Print output and don't return it. * Taking input is handled automatically. */ int cd; for(int i=start;i<end;i+=step){ cd=(i-32)/1.8; cout<<i<<" "<<cd<<endl; } }
Comments
Post a Comment