本题要求编写c语言程序,计算华氏温度150°F对应的摄氏温度。计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型。
时间: 2024-06-13 22:06:04 浏览: 17
以下是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语言程序,计算华氏温度150°F对应的摄氏温度。计算公式:C=5×(F−32)/9,式中:C表示摄氏温度,F表示华氏温度,输出数据要求为整型。
好的,以下是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语言编写给定一个华氏温度F,本题要求编写程序,计算对应的摄氏温度C。计算公式:C=5×(F−32)/9。题目保证输入与输出均在整型范围内。
好的,我明白了您的要求。以下是C语言代码实现:
```c
#include<stdio.h>
int main(){
int F,C;
scanf("%d",&F);
C=5*(F-32)/9;
printf("%d\n",C);
return 0;
}
```
如果您输入一个华氏温度F,该程序会自动将其转换为对应的摄氏温度C,并输出结果。注意,在该程序中,输入和输出分别使用了scanf()和printf()函数。
相关推荐
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)