温度转换PHP,华氏温度转换为摄氏度的程序

在华氏温度为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 

//转换华氏到摄氏

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值