count number of even number and odd number in the given integer set

 

In this post you can learn to find the number of even and odd number in the given integer. The code is given below. The code was in c program.


#include<stdio.h>
int main()
{
    int n,a[100],b=0,c=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2==0)
        {
            b++;
        }
        else
        {
            c++;
        }
    }
    printf("Even : %d \n Odd: %d",b,c);
}


INPUT:

3
1
2
10

OUTPUT:

Even : 2 
Odd: 1

 

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post