#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
语句不起作用。
答案 0 :(得分:1)
else if ( 70>=age>50 ){
在C中,这不是你怎么做的。而是试试这个 -
else if (age>50 && age <=70){ // age in between 50 and 70(including)