Monday, January 21, 2013

write a program to find the number of even integers and odd integers in a given array

#include<studio.h>
#include<conio.h>
main()
{
  int a[5],count_even=0,count_odd=0,i;

   for(i=0;i<5;i++)

       scanf("%d",&a[i]);
/* display the number of odd and even intergers */
for(i=0;i<5;i++)
{
   if((a[i]%2 ==0))
          count_even++;
    if((a[i]%2==1))
          count_odd++;
}
printf("%d %d",count_even,count_odd);
getch();
}

No comments:

Post a Comment