1
0

C5-4.c 410 B

1234567891011121314151617
  1. #include <stdio.h>
  2. #define SUM 100000
  3. int main()
  4. {
  5. float amount,aver,total;
  6. int i;
  7. for (i=1,total=0;i<=1000;i++)
  8. {
  9. printf("please enter amount:");
  10. scanf("%f",&amount);
  11. total= total+amount;
  12. if (total>=SUM) break;
  13. }
  14. aver=total/i;
  15. printf("num=%d\naver=%10.2f\n",i,aver);
  16. return 0;
  17. }