gpt4 book ai didi

c - ine 10 中 ';' 标记之前应为 '{'

转载 作者:行者123 更新时间:2023-11-30 21:37:41 24 4
gpt4 key购买 nike

我是编程新手,这就是我尝试编译该程序时得到的结果。你能帮忙吗?

#include<stdio.h>
int main ()

{

int Fahrenheit;

int Celcius;

int choice;

int temperature;

printf ( "What do you want to do? (1/2) \n 1. Fahrenheit to Celcius \n. 2. Celcius to Fahrenheit \n. "

if ( 1 )

{

printf ( "Enter Fahrenheit \n." )

scanf ( "%d", &Fahrenheit );

Celcius=( Fahrenheit-32 )*5/9;

print( "The temperature in Celcius is %d \n", Celcius );

}

else ( 2 )

{

printf ( "Enter celcius\n" );

scanf ( "%d", &Celcius );

Fahrenheit=Celcius*((9/5)+32);

printf ( "The temperature in Fahrenheit is %d \n, Fahrenheit );

}

}

最佳答案

这是我发现的所有编译错误的列表。

第一个问题在这一行:

printf ( "你想做什么?(1/2)\n 1. 华氏温度到摄氏温度\n。2. 摄氏温度到华氏温度\n。"

您缺少右括号和分号。

另一个在这里:

printf("输入华氏度\n。")

你最后漏掉了一个分号。

另一个问题是在这一行:

其他 (2)

else 没有像 if() 这样的条件 block ,因此 ( 2 ) 被视为需要执行的语句如果您的 else 所属的 if 中的条件不满足。但是,它缺少一个“;”最后,因此出现错误。 { } 包含的 block 与您的 else 根本不相关。

这是另一个:

printf (“华氏温度为 %d\n, Fahrenheit ); 您的字符串文字中缺少结束符

通常,即使您纠正了所有这些错误,您的代码仍然不会执行您期望的操作。我建议您在尝试编码之前先坐下来阅读一本关于编程的好书或初学者教程。

关于c - ine 10 中 ';' 标记之前应为 '{',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28463123/

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