Write a program to find the count of all even no’s and odd no’s in an array / list code example
Example 1: Print Odd Even Negative Integer Count
#include<stdio.h>
int main()
{
int n,i,e=0,o=0,ne=0;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]<0) ne++;
else if(a[i]%2==0&&a[i]>=0) e++;
else o++;
}
printf("%d %d %d",o,e,ne);
}
Example 2: Print Odd Even Negative Integer Count
n,neg,odd,eve,m=int(input()),0,0,0,[int(i) for i in input().split()]
for i in m:
if i<0:
neg+=1
elif i%2==0 :
eve+=1
else:
odd+=1
print("{0} {1} {2}".format(odd,eve,neg))