Program to count Even & Odd Elements in an Array

#include<stdio.h>
#include<conio.h>
void main()
{
int x[5],i,en=0,od=0;
clrscr();
  for(i=0;i<5;i++)
  {
  printf("\nEnter No ");
  scanf("%d",&x[i]);
  }
  for (i=0;i<5;i++)
  {
  printf("\n\tx[%d]==%d",i,x[i]);
     if(x[i]%2==0)
     en=en++;
     else
     od=od++;
  }
  printf("\n\nTotal Even %d",en);
  printf("\n\nTotal Odd %d",od
  );
getch();
}

Leave a Reply