1
0

boolean.c 510 B

123456789101112131415161718192021
  1. // boolean.c -- using a _Bool variable
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. long num;
  6. long sum = 0L;
  7. _Bool input_is_good;
  8. printf("Please enter an integer to be summed ");
  9. printf("(q to quit): ");
  10. input_is_good = (scanf("%ld", &num) == 1);
  11. while (input_is_good)
  12. {
  13. sum = sum + num;
  14. printf("Please enter next integer (q to quit): ");
  15. input_is_good = (scanf("%ld", &num) == 1);
  16. }
  17. printf("Those integers sum to %ld.\n", sum);
  18. return 0;
  19. }