华氏温度转换为摄氏度的程序
在华氏温度为n的情况下,面临的挑战是将给定温度转换为摄氏度并显示出来。
示例
Input 1-: 132.00 Output -: after converting fahrenheit 132.00 to celsius 55.56 Input 2-: 456.10 Output -: after converting fahrenheit 456.10 to celsius 235.61
为了将温度从华氏温度转换为摄氏温度,有下面的公式
T(°C)=(T(°F)-32)×5/9
其中,T(°C)是摄氏温度,T(°F)是华氏温度
下面使用的方法如下-
浮动变量中的输入温度,我们说华氏温度
应用公式将温度转换为摄氏
打印摄氏度
算法
Start
Step 1-> Declare function to 转换华氏到摄氏
float convert(float fahrenheit)
declare float Celsius
Set celsius = (fahrenheit - 32) * 5 / 9
return Celsius
step 2-> In main() declare and set float fahrenheit = 132.00
Call convert(fahrenheit)
Stop示例
#include <stdio.h>
//转换华氏到摄氏
float convert(float fahrenheit) {
float celsius;
celsius = (fahrenheit - 32) * 5 / 9;
return celsius;
}
int main() {
float fahrenheit = 132.00;
printf("after converting fahrenheit %.2f to celsius %.2f ",fahrenheit,convert(fahrenheit));
return 0;
}输出结果
如果我们运行以上代码,它将在输出后产生
after converting fahrenheit 132.00 to celsius 55.56
热门推荐
10 英文简短唯美祝福语大全
11 祝福语生日男朋友简短
12 生了女孩祝福语简短的
13 同学分开祝福语简短
14 新年的好祝福语简短
15 新年简短的英文祝福语
16 求助短信生日祝福语简短
17 对同事简短生日祝福语
18 妈妈生日贺卡祝福语 简短