C++ experiment 02 (02) Fahrenheit temperature to Celsius

Title description
Write a function convert() to convert Fahrenheit temperature to Celsius temperature. The conversion formula is:
C=(F-32)* 5 /9
requires an inline function to be implemented. Call this function in main().
Note: F is double type.
Input description
Fahrenheit temperature
Output description
Celsius temperature
Input sample
100
Output sample
Fahrenheit temperature is: 100, the corresponding Celsius temperature is: 37.7778 (Chinese punctuation)

#include <iostream>
using namespace std;
inline double f(double h )
{
    
    
	return (h-32)*5/9  ;
}


int main()
{
    
    
	double h=0;
	cin>>h;
	cout<<"华氏温度为:"<<h<<",对应的摄氏温度为:"<<f(h);
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_44179485/article/details/105890629
Recommended