請幫忙看看下面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;
2016-03-18