循环条件与结果冲突问题
#include <stdio.h>void main()
{
int i,sum,n;
float money,ave;
sum=2,n=2;
i=2;
while (sum<=100)
{
n=n*2;
sum=sum+n;
i++;
}
money=sum*0.8;
ave=money/i;
printf("%4d%4d%4d\n",sum,i,n);
printf("the ave is :%f\n",ave);
}
已经规定sum<=100,为什么输出来时是126呢?