I have written a program to count the number of even and odd numbers entered from a list; but currently it wont work correctly, think its my modulus operators in the wrong place, but not 100%. Pretty knew to this.
/* Program to count the no of even and odd numbers*/
#include <stdio.h>
void main( )
{
int a[100], n, count_odd=0, count_evn=0,I;
printf("Enter numbers in array");
scanf("%d",&n);
printf("Enter the integars, seperated by a space");
for (I=0;I < n;I++);
scanf("%d",&a[I]);
for(I=0;I < n;I++)
{
if(a[I] % 2 == 0)
count_evn++;
else
count_odd++;
}
printf("There are %d negative numbers in the arrayn\n",count_odd);
printf("There are %d positive numbers in the arrayn",count_evn);
}
Any suggestions would be appreciated. Thanks.