编写C语言程序,计算华氏温度150°F对应的摄氏温度。计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型。
时间: 2024-03-25 11:41:03 浏览: 46
好的,以下是C语言程序的代码:
```c
#include <stdio.h>
int main() {
int fahrenheit = 150;
int celsius = 5 * (fahrenheit - 32) / 9;
printf("%d°F 对应的摄氏温度为 %d℃", fahrenheit, celsius);
return 0;
}
```
程序运行结果为:
```
150°F 对应的摄氏温度为 65℃
```
注意事项:本程序中使用的计算公式为C=5×(F−32)/9,所有计算中的数值均为整型,输出结果也是整型。
相关问题
本题要求编写c语言程序,计算华氏温度150°F对应的摄氏温度。计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型。
以下是C语言程序,计算华氏温度150°F对应的摄氏温度:
```c
#include <stdio.h>
int main()
{
int f = 150;
int c = 5 * (f - 32) / 9;
printf("Celsius = %d\n", c);
return 0;
}
```
输出结果为:
```
Celsius = 65
```
用c语言编写程序,计算并输出华氏温度为80F所对应的摄氏温度C。 转换公式为:C=5* (F-32) /9
```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;
}
```