-- --

Find the number of even/odd integers in an array

To know the number of even/odd numbers, we use the modulus function. ‘%’
The program is:

#include<stdio.h>
#include<conio.h>
#define MAX 99
main()
{
 int a[MAX],i,n,even,odd;
 printf("Enter the number of elements in the array\n");
 scanf("%d",&n);
 printf("Enter the elements");
 for(i=0;i<n;i++)
  scanf("%d",&a[i]);
 even=0;
 odd=0;
 for(i=0;i<n;i++)
 {
  if(a[i]%2==0)
   even++;
  else if(a[i]%2!=0)
   odd++;
 }
 printf("The number of even elements are:%d\nThe number of odd elements are:%d",even,odd);
 getch();
 }

kaliadevansh has written 15 articles

3 thoughts on “Find the number of even/odd integers in an array

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>