How to write program that 'Convert Fahrenheit to Kelvin' ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write program that 'Convert Fahrenheit to Kelvin' ?

Write a program to convert a temperature in degrees Fahrenheit to the kelvin scale. Data Requirements Problem Input  int fahrenheit /* temperature in degrees Fahrenheit    */ Problem Output  double kelvin /* temperature on the kelvin scale       */ Relevant Formula kelvin = 5/9 (fahrenheit − 32) + 273.15

7th Sep 2016, 7:07 AM
Ha Nguyen
Ha Nguyen - avatar
3 Answers
+ 2
double FtoK(int f) { return ((double)f-32.0)*5.0/9.0+273.15; }
7th Sep 2016, 8:14 AM
Zen
Zen - avatar
+ 2
That's a function, which can be called in the following way: http://code.sololearn.com/clUd0UKVfsjE/# #include <iostream> using namespace std; double convertToKelvin(double f) { return (f - 32) * 5 / 9 + 273.15; } int main() { double fahrenheit = 22.32; double result = convertToKelvin(fahrenheit); cout << fahrenheit << " fahrenheit = " << result << " kelvin." << endl; return 0; }
7th Sep 2016, 10:18 PM
Liam
Liam - avatar
- 1
this doesn't make sense much
7th Sep 2016, 9:23 PM
Ha Nguyen
Ha Nguyen - avatar