Home » C solved programs » C basic programs

C program to check whether a given number is EVEN or ODD



C program for EVEN or ODD: Here, we are reading an integer number from the user and checking whether it is EVEN or ODD.

Given an integer number and we have to check it is EVEN or ODD using C program.

The numbers which are divisible by 2 are EVEN numbers and which are not divisible by 0 are not as ODD numbers.

To check whether given number is EVEN or ODD, we are checking modulus by dividing number by 2, if the modulus is 0, then it will be completely divisible by 2 hence number will be EVEN or its will be ODD.

Example 1:

    Input:
    Enter number: 12
    Output:
    12 is an EVEN number.

Example 2:

    Input:
    Enter number: 19
    Output:
    19 is an ODD number.


C program to check EVEN or ODD

/* c program to check whether number is even or odd*/
#include <stdio.h>
int main()
{
  
    int num;
 
    printf("Enter an integer number: ");
    scanf("%d",&num);
 
    /*If number is divisible by 2 then number 
    is EVEN otherwise number is ODD*/
 
    if(num%2==0)
        printf("%d is an EVEN number.",num);
    else
        printf("%d is an ODD number.",num);
 
    return 0;
}

Output

    First Run:
    Enter an integer number: 123
    123 is an ODD number.

    Second Run:
    Enter an integer number: 110
    110	 an EVEN number.





Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.