用c语言编写程序,计算并输出华氏温度为80F所对应的摄氏温度C。 转换公式为:C=5* (F-32) /9
时间: 2024-05-02 18:22:09 浏览: 13
```c
#include <stdio.h>
int main() {
float fahrenheit = 80; // 摄氏温度
float celsius; // 华氏温度
celsius = 5 * (fahrenheit - 32) / 9;
printf("华氏温度为 %.2f°F,对应的摄氏温度为 %.2f°C", fahrenheit, celsius);
return 0;
}
```
相关问题
编写程序,计算并输出华氏温度为80F所对应的摄氏温度C。 转换公式为:C=5* (F-32) /9
```python
fahrenheit = 80
celsius = 5 * (fahrenheit - 32) / 9
print("华氏温度为", fahrenheit, "度,对应的摄氏温度为", celsius, "度。")
```
输出结果为:
```
华氏温度为 80 度,对应的摄氏温度为 26.666666666666668 度。
```
用c语言编写程序计算并输出华氏温度80F所对应的摄氏温度C。转换公式为:C=5/9×(F-32),并利用float型数据进行运算。
答案:
华氏温度80F所对应的摄氏温度C为26.666666。以下是用C语言编写的程序:
#include <stdio.h>
int main()
{
float fahrenheit = 80;
float celsius = 5.0 / 9 * (fahrenheit - 32);
printf("%.2fF = %.2fC", fahrenheit, celsius);
return 0;
}
输出结果为:
80.00F = 26.67C