为什么第二个程序无法跳出?
为什么第二个程序无法跳出?
第一个程序,当price等于1000000.0时会从WHILE中跳出
#include"stdio.h"
#define SEN 1000000.0
#define RATE .02
int main()
{
float price,salestax;
printf("Enter a price:");
scanf("%f",&price);
while(price!=SEN)
{
salestax=RATE*price;
printf("The sales tax is $%5.2f",salestax);
printf("\nEnter a price:");
scanf("%f",&price);
}
return 0;
}
而第二个当输入PRICE为1000000.0时却无法跳出,有什么错误吗?但我始终没有找出来
#include"stdio.h"
#define SEN 1000000.0
#define RATE .02
int main()
{
float price,salestax;
printf("Enter a price:");
while(scanf("%f",&price)!=SEN)
{
salestax=RATE*price;
printf("The sales tax is $%5.2f",salestax);
printf("\nEnter a price:");
}
return 0;
}