错误警告正常吗
/* Program 3.7 A confused recruiting policy */#include <stdio.h>
#include <stdbool.h>
int main(void)
{
int age = 0; //年龄
int college = 0; //大学
int subject = 0; //专业
bool interview = false; //条件为假
// 获取求职者条件
printf("\nWhat college? 1 for Harvard, 2 for Yale, 3 for other: ");
scanf("%d", &college);
printf("\nWhat subject? 1 for Chemistry, 2 for economics, 3 fot other: ");
scanf("%d", &subject);
printf("\nHow old is the applicant? ");
scanf("%d", &age);
// 检测求职者
if((age>25 && subject == 1) && (college == 1 || college == 3)) // 25岁以上,化学专业非耶鲁大学毕业
interview = true;
if(college == 2 && subject == 1); // 化学专业的耶鲁大学毕业
interview = true;
if((age<28 && college == 1) && subject ==2); // 28岁以下, 经济专业哈佛大学毕业
interview = true;
if((age>25 &&college == 2) && (subject == 3 || subject == 2)); // 25岁以上, 非化学专业的耶鲁大学毕业
interview = true;
//结果
if(interview)
printf("\n\nGive 'em an interview\n");
else
printf("\n\nReject 'em\n");
return 0;
}
这是教课书列题
编译的时候提示
Building 3.7.obj.
C:\Users\Administrator\Documents\Pelles C Projects\3.7\3.7.c(34): warning #2154: Unreachable code.
Done.
但是代码可以执行,它这个警告合理吗?如何避免?
如果没有这个警告该多好
我把警告的代码删除,又感觉整个代码不太完整了