Total no of even and odd numbers in an array in C


Given an array of integers, count the total number of odd elements and even elements in the array and display them as output.

Source Code

//Program to find total no of even and odd numbers in an array in C Programming.
 
#include<stdio.h>
 
int main()
{
    int a[100],i,n,e=0,o=0;
    printf("\nEnter The Limit : ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("\nEnter The Value : ");
        scanf("%d",&a[i]);
        a[i]%2==0?e++:o++;
        /*if(a[i]%2==0)
        {
            e++;
        }
        else
        {
            o++;
        }*/
    }
    printf("\nTotal Even No is : %d",e);
    printf("\nTotal Odd  No is : %d",o);
     return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes