用C ++将华氏温度转换为开尔文的程序
在华氏温度为n的情况下,面临的挑战是将给定温度转换为开尔文并显示出来。
示例
Input 1-: 549.96 Output -: Temperature in fahrenheit 549.96 to kelvin : 561.256 Input 2-: 23.45 Output -: Temperature in fahrenheit 23.45 to kelvin : 268.4
为了将温度从华氏温度转换为开氏温度,下面给出了一个公式
K=273.5+((F-32.0)*(5.0/9.0))
其中,K是开氏温度,F是华氏温度
下面使用的方法如下-
浮动变量中的输入温度,我们说华氏温度
应用公式将温度转换为开尔文
打印开尔文
算法
Start Step 1-> Declare function to 转换华氏到开尔文 float convert(float fahrenheit) return 273.5 + ((fahrenheit - 32.0) * (5.0/9.0)) step 2-> In main() declare and set float fahrenheit = 549.96 Call convert(fahrenheit) Stop
示例
#include<iostream>
using namespace std ;
//转换华氏到开尔文
float convert(float fahrenheit) {
return 273.5 + ((fahrenheit - 32.0) * (5.0/9.0));
}
int main() {
float fahrenheit = 549.96;
cout << "Temperature in fahrenheit "<<fahrenheit<<" to kelvin : "<<convert(fahrenheit) ;
return 0;
}输出结果
如果我们运行以上代码,它将在输出后产生
Temperature in fahrenheit 549.96 to kelvin : 561.256
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短