fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int num, pos = 0, neg = 0, zero = 0;
  5.  
  6. printf("Enter numbers (enter -999 to stop):\n");
  7. while (1) {
  8. scanf("%d", &num);
  9. if (num == -999) // stop condition
  10. break;
  11.  
  12. if (num > 0) pos++;
  13. else if (num < 0) neg++;
  14. else zero++;
  15. }
  16.  
  17. printf("\nPositive: %d\nNegative: %d\nZero: %d\n", pos, neg, zero);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5324KB
stdin
0
78
-7
0
-999
stdout
Enter numbers (enter -999 to stop):

Positive: 1
Negative: 1
Zero: 2