gpt4 book ai didi

c - 为什么这个 C 示例中是 "fahr-32"而不是简单的 "32"?

转载 作者:行者123 更新时间:2023-11-30 19:56:28 25 4
gpt4 key购买 nike

我想知道为什么在这个例子中,32 值前面有 fahr- 。是否有必要或只是指定某些内容?

#include <stdio.h>

/* print Fahrenheit-Celsius table
for fahr = 0, 20, ..., 300 */
main()
{
int fahr, celsius;
int lower, upper, step;

lower = 0; /* lower limit of temperature scale */
upper = 300; /* upper limit */
step = 20; /* step size */

fahr = lower;
while (fahr <= upper) {
celsius = 5 * (fahr-32) / 9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
}

最佳答案

在此示例中,您将从华氏温度转换为摄氏温度。

此示例中的

fahr-32 表示获取名为 fahr 的变量(包含华氏温度)中的值并减去 32。因此 fahr code> 是变量名,- 表示减号。

关于c - 为什么这个 C 示例中是 "fahr-32"而不是简单的 "32"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27004442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com