华氏0~300,每隔20华氏度输出一个对应的摄氏度。c语言
时间: 2024-05-14 14:13:43 浏览: 12
好的,请稍等一下。
以下是 C 语言代码:
```c
#include <stdio.h>
int main()
{
int fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
fahr = lower;
while (fahr <= upper) {
celsius = 5 * (fahr - 32) / 9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
return 0;
}
```
这段代码可以将华氏温度从 0 到 300 每隔 20 度转换为摄氏温度并输出。
相关问题
编写一个华氏度转换成摄氏度的C语言代码
以下是华氏度转换成摄氏度的C语言代码:
#include <stdio.h>
int main() {
float fahrenheit, celsius;
printf("请输入华氏度: ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("%.2f 华氏度 = %.2f 摄氏度\n", fahrenheit, celsius);
return 0;
}
帮我写一个华氏度转摄氏度的c语言程序
好的,以下是华氏度转摄氏度的 C 语言程序:
```c
#include <stdio.h>
int main() {
float fahrenheit, celsius;
printf("请输入华氏度: ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("摄氏度为: %.2f\n", celsius);
return ;
}
```
请注意,以上程序仅供参考,可能存在错误或不足之处。
相关推荐
![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)