用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
热门推荐
1 训练狗狗工作
4 狗狗定点排便训练
5 狗狗训练吠叫
6 狗狗尿垫训练
7 狗狗训练座
8 狗狗训练攻略
9 狗狗训练记
10 做训练狗狗
11 狗狗训练词
12 狗狗谢谢怎么训练
13 狗狗训练如厕
14 狗狗太凶怎么训练
15 狗狗训练它
16 狗狗克制训练
17 训练基地狗狗
18 怎么样训练狗狗大小硬