1
0

parta.c 687 B

1234567891011121314151617181920212223242526272829
  1. // parta.c --- various storage classes
  2. // compile with partb.c
  3. #include <stdio.h>
  4. void report_count();
  5. void accumulate(int k);
  6. int count = 0; // file scope, external linkage
  7. int main(void)
  8. {
  9. int value; // automatic variable
  10. register int i; // register variable
  11. printf("Enter a positive integer (0 to quit): ");
  12. while (scanf("%d", &value) == 1 && value > 0)
  13. {
  14. ++count; // use file scope variable
  15. for (i = value; i >= 0; i--)
  16. accumulate(i);
  17. printf("Enter a positive integer (0 to quit): ");
  18. }
  19. report_count();
  20. return 0;
  21. }
  22. void report_count()
  23. {
  24. printf("Loop executed %d times\n", count);
  25. }