请帮忙看看下面C程序
下面c程序 double total = 0.0; 这一句为何放在第四行可以,而在放在第八行就不行,
#include <stdio.h>
int main(void)
{
const double unit_price = 3.50;
// double total = 0.0; //放在这里就可以
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;