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

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

  1. Elane says:

    Thanks for the marvelous posting! I actually enjoyed reading
    it, you may be a great author.I will remember to bookmark your blog and will come back from now on. I want
    to encourage you to definitely continue your great writing, have
    a nice afternoon!

  2. Julianne says:

    I blog often and I seriously thank you for your content. The article
    has really peaked my interest. I am going to take a note of your website
    and keep checking for new information about once per week.
    I opted in for your Feed as well.

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>