求高手解决一下下面的问题?
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/18 19:22:04
求高手解决一下下面的问题?
#include
int main(void)
{
const double unit_price = 3.50;
int quantity = 0;
printf("Enter the number that you want to buy:");
scanf(" %d", &quantity);
double total = 0.0;
if(quantity > 10)
total = quantity*unit_price*0.95;
else
total = quantity*unit_price;
printf("The price for %d is $%.2f\n", quantity, total);
return 0;
}
这个程序输不出来,求解?
在编译时出现错误,我觉的没有错误呀!但是显示错误,不知道为什么
#include
int main(void)
{
const double unit_price = 3.50;
int quantity = 0;
printf("Enter the number that you want to buy:");
scanf(" %d", &quantity);
double total = 0.0;
if(quantity > 10)
total = quantity*unit_price*0.95;
else
total = quantity*unit_price;
printf("The price for %d is $%.2f\n", quantity, total);
return 0;
}
这个程序输不出来,求解?
在编译时出现错误,我觉的没有错误呀!但是显示错误,不知道为什么
C的话,把double total = 0.0;放到printf前面去,C只能在程序开头声明,我放在开头,可以运行