我刚刚从我的项目中创建了一个C ++问题,我编译了程序并给了我一个错误,但是给了我一个警告,我无法运行或测试程序。
#include <iostreamn.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int grossincome,totaldeduction,tax,output;
cout<<"Input gross income: "<<endl;
cin>>grossincome;
cout<<"Input total deductions: "<<endl;
cin>>totaldeduction;
if (grossincome > 100000)
{
tax = (grossincome * .20);
output = (grossincome - totaldeduction - tax);
}
else if((grossincome <= 100000) && (grossincome >= 50000))
{
tax = (grossincome * .15);
output = (grossincome - totaldeduction - tax);
}
else if(grossincome < 50000)
{
tax = (grossincome * .10);
output = (grossincome - totaldeduction - tax);
}
cout<<"Output: "<<output;
system("pause");
return 0;
}
我在所有如果声明中收到警告,说明以下信息。
WARNING message: "Warning Q4.CPP 16: Constant out of range in comparison"
"Warning Q4.CPP 21: Constant out of range in comparison"
"Warning Q4.CPP 21: Constant out of range in comparison"
"Warning Q4.CPP 26: Constant out of range in comparison"
答案 0 :(得分:6)
Turbo C / C ++是一个旧的编译器。 int的范围是-32768到+32767。你可以切换到更好的标准编译器(如gcc)或使用long修饰符。