Q:

Write a C Program to check whether number is EVEN or ODD

0

Write a C Program to check whether number is EVEN or ODD. Here’s simple Program to check whether number is EVEN or ODD in C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24

An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15

To check whether an integer is even or odd, the remainder is calculated when it is divided by 2 using modulus operator %. If remainder is zero, that integer is even if not that integer is odd.

Below is the source code for C Program to check whether number is EVEN or ODD which is successfully compiled and run on Windows System to produce desired output as shown below :

SOURCE CODE : :

/*  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("\n%d is an EVEN number.",num);
    else
        printf("\n%d is an ODD number.",num);

    return 0;
}

OUTPUT : :

First Run:

    Enter an integer number: 27
    
    27 is an ODD number.

Second Run:

    Enter an integer number: 88
    
    88 is an EVEN number.

Above is the source code for C Program to check whether number is EVEN or ODD which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Number Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to find largest number among three numbe... >>
<< Write a C Program to display Armstrong numbers bet...