函数'If'的隐式声明

Implicit Declaration of Function 'If'

本文关键字:声明 If 函数      更新时间:2023-10-16

我目前正在尝试创建一个快速程序,让你有机会在10次猜测中猜测一个预定的数字(我希望这个数字是28)。如果你符合猜测,你会被告知"恭喜!你猜对了数字。"如果你没有达到猜测,你将被告知"再试一次!"直到你的尝试次数用完或猜对为止

这是我当前的代码: int main(void){

int Chance, Guess;
printf ("You have 10 chances to guess the number between 0-50.n");
for (Chance=0; Chance<10; Chance++)
{
    scanf("%d",&Guess);
    If (Guess==28)
        printf("Congrats! You have guess the number!");
    Else If (Guess!=28)
        printf("Try Again!n");
    }
printf("You are all out of tries.");    
return 0;

}

这是我的错误列表:编译错误时间:0内存:0信号:0

prog.c:在函数'main'中:

prog.c:9:3:警告:函数"If"的隐式声明[-Wimplicit函数声明]如果(Guess==28)^

prog.c:10:4:错误:应为";"printf"之前printf("恭喜!你猜对了数字!");^

prog.c:11:3:错误:未知类型名称"Else"Else If(猜测!=28)^prog.c:11:17:错误:在"!="之前应为")"代币Else If(猜测!=28)^

如有任何帮助,我们将不胜感激

ifelse子句以小写字母开头。实际上,所有的C和C++保留字都以小写字母或下划线开头。

C和C++语言都区分大小写。