fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n, i, even = 0, odd = 0, positive = 0, negative = 0;
  5. printf("Enter the size of the array: ");
  6. scanf("%d", &n);
  7.  
  8. int arr[n];
  9. printf("Enter %d elements of the array:\n", n);
  10. for (i = 0; i < n; i++) {
  11. scanf("%d", &arr[i]);
  12.  
  13. // Check for even and odd
  14. if (arr[i] % 2 == 0) {
  15. even++;
  16. } else {
  17. odd++;
  18. }
  19.  
  20. // Check for positive and negative
  21. if (arr[i] > 0) {
  22. positive++;
  23. } else if (arr[i] < 0) {
  24. negative++;
  25. }
  26. }
  27.  
  28. printf("Even: %d\nOdd: %d\nPositive: %d\nNegative: %d\n", even, odd, positive, negative);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5284KB
stdin
10
1 2 0 -3 -8 3 4 6 1 5
stdout
Enter the size of the array: Enter 10 elements of the array:
Even: 5
Odd: 5
Positive: 7
Negative: 2