C语言 warning C4700: local variable 'salary' used without having been initialized
本人是C语言初学者,这个程序运行时发生了错误,没有error,但有个warning#include<stdio.h>voidmain(void){doublerate,t...
本人是C语言初学者,
这个程序运行时发生了错误,没有error,但有个warning
#include <stdio.h>
void main(void)
{
double rate,tax,salary;
printf("请输入月薪:");
scanf("%f",salary);
if (salary<=850)
{ rate=0;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(850<salary&&salary<=1350)
{ rate=0.05;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(1350<salary&&salary<=2850)
{ rate=0.1;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(2850<salary&&salary<=5850)
{ rate=0.15;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(5850<salary)
{ rate=0.2;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
} 展开
这个程序运行时发生了错误,没有error,但有个warning
#include <stdio.h>
void main(void)
{
double rate,tax,salary;
printf("请输入月薪:");
scanf("%f",salary);
if (salary<=850)
{ rate=0;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(850<salary&&salary<=1350)
{ rate=0.05;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(1350<salary&&salary<=2850)
{ rate=0.1;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(2850<salary&&salary<=5850)
{ rate=0.15;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
else if(5850<salary)
{ rate=0.2;
tax=rate*(salary-850);
printf("tax=% .2lf",tax);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询