简单'否则如果'声明不起作用

时间:2016-02-06 05:25:12

标签: c

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int age;

    printf("Hello world! Please enter your age\n");
    scanf("%d", &age);
    if (age <= 50) {
        printf("You are still young to change the world\n");
    }
    else if (70 >= age >50) {
        printf("You are now old, but don't worry\n");
    }
    else {
        printf("You are extremely old\n");
    }
    return 0;
}

我进入了51岁,它给了#34;你已经非常老了#34; else if语句不起作用。

1 个答案:

答案 0 :(得分:1)

else if ( 70>=age>50 ){

在C中,这不是你怎么做的。而是试试这个 -

else if (age>50 && age <=70){    // age in between 50 and 70(including)