这个 illegal else without matching if 怎么解决

#include<stdio.h>
void main()
{
int date , price, x;
printf("Enter the date returning the books \n");
scanf("%d",&date);

if(date <= 5)
    price=50;
    printf("The price is %d",price);    
else if((date > 5) && (date <= 10))
    x=date-5;
    price=50+x;
    printf("The price is %d \n",price);
else if((date >10) && (date <= 30))
    x=date-10;
    price=55+5*x;
    printf("The price is %d \n",price);
else
    printf("You'd lost the member qualification");

}

前面if下面有多条语句,但是没加大括号,后面也一样

img


修改后:

img

#include<stdio.h>
int main()
{
int date , price, x;
printf("Enter the date returning the books \n");
scanf("%d",&date);

if(date <= 5){
    price=50;
    printf("The price is %d",price);}
else if((date > 5) && (date <= 10)){
    x=date-5;
    price=50+x;
    printf("The price is %d \n",price);}
else if((date >10) && (date <= 30)){
    x=date-10;
    price=55+5*x;
    printf("The price is %d \n",price);}
else
    printf("You'd lost the member qualification");
}


如果if else语句后面超过了一行代码,要加大括号括起来哦。

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632