标题:为什么第二个程序无法跳出?
取消只看楼主
月之神
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-10-26
 问题点数:0 回复次数:1 
为什么第二个程序无法跳出?

为什么第二个程序无法跳出?
第一个程序,当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;
}

搜索更多相关主题的帖子: price SEN printf 
2006-11-03 16:45
月之神
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2006-10-26
得分:0 
谢谢拉
同学发的
2006-11-07 10:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-100564-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.265560 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved