C program to check number is odd or even

Check Number is Odd or Even

C program to check number is odd or even

A number exactly divisible by 2 with remainder 0, is known as even number. If any number modulo divided by 2 equals 0 then, the number is even otherwise odd. In the Programming world, have an Arithmetic Operator called % (Module) to check the remainder of the division. Let’s use this operator to find the remainder. If the remainder is 0, then the number is even else odd number.

#include <stdio.h>
#include<conio.h>
void main()
{
    int num;
    clrscr();
printf("\n...Welcome To EduNews.Tech... ");
    /* Input number from user */
    printf("\n\nEnter any number to check whether it is even or odd: ");
    scanf("%d", &num);

    /* Check if the number is divisible by 2 then it is even */
    if(num % 2 == 0)
    {
    /* num % 2 is 0 */
    printf("The Entered number is Even.");
    }
    else
    {
    /* num % 2 is 1 */
    printf("The Entered number is Odd.");

    }
    printf("\n\n\n\n\t\t\tThankyou for Joining Us !");
    printf("\n\t\t\t!Regards EduNews !");
    getch();
}

Program Output:

odd even

In this program we allow the user to enter an integer and then checks whether that number is even or odd using the If statement.

I hope this post helps you to understand Odd-Even number and its implementation in C programming language.

Keep coding 🙂

3 thoughts on “C program to check number is odd or even”

Leave a Reply

Your email address will not be published. Required fields are marked *