Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
else语句产生c 13中所需的标识符_C - Fatal编程技术网

else语句产生c 13中所需的标识符

else语句产生c 13中所需的标识符,c,C,我是C语言的初学者,还在学习这门语言 我说不出是什么错误 #include<stdio.h> #include<math.h> void main (void) { float hours,rate; printf("Enter the number of hours worked in this week:\n"); scanf("%f",&hours); printf("Enter the pay rate\n"); s

我是C语言的初学者,还在学习这门语言

我说不出是什么错误

#include<stdio.h>
#include<math.h>
void main (void)
{
    float hours,rate;
    printf("Enter the number of hours worked in this week:\n");
    scanf("%f",&hours);
    printf("Enter the pay rate\n");
    scanf("%f",&rate);
    if ( hours > 40 );
        printf("more than 40");

    else{
        printf("less than 40");
    }
}
#包括
#包括
真空总管(真空)
{
浮动小时数、浮动率;
printf(“输入本周的工作小时数:\n”);
scanf(“%f”、&hours);
printf(“输入付款率”);
scanf(“%f”、&rate);
如果(小时数>40);
printf(“超过40”);
否则{
printf(“少于40”);
}
}

//c:13预期标识符

问题是此处分号放错了
if(小时数>40)只需删除分号。正确缩进代码以帮助检测此类错误是一种很好的做法。

我想他想要这样的东西: 当然,正如前面提到的,问题是
if
语句后面的分号放错了位置

#include<stdio.h>
#include<math.h>

void main (void)
{
    float hours,rate;
    printf("Enter the number of hours worked in this week:\n");
    scanf("%f",&hours);
    printf("Enter the pay rate\n");
    scanf("%f",&rate);
    if (hours > 40)
    {
        printf("more than 40");
    }
    else
    {
        printf("less than 40");
    }
}
#包括
#包括
真空总管(真空)
{
浮动小时数、浮动率;
printf(“输入本周的工作小时数:\n”);
scanf(“%f”、&hours);
printf(“输入付款率”);
scanf(“%f”、&rate);
如果(小时数>40)
{
printf(“超过40”);
}
其他的
{
printf(“少于40”);
}
}

使用括号也很好{}对不起,缩进是什么意思?如果我打扰了您,我很抱歉,谢谢您代码运行:Dindent的意思是像@Mike just这样的格式did@cleblanc除了因为额外的“;”;-)Mike indent是错误的之外