Checking for Odd or Even in C Programming


This program is a simple program that takes an integer input from the user and checks if it is an even number or odd number. It uses the modulus operator(%) to check the remainder of the number when divided by 2. If the remainder is 0, it means the number is divisible by 2 and therefore it is an even number. Else, the number is not divisible by 2 and is an odd number. The program then prints the result using the printf statement.


Source Code

/*
Any integer is input through the keyboard. Write a program to find out
whether it is an odd number or even number.
(Hint: Use the % (modulus) operator)
*/
#include<stdio.h>
 
int main()
{
    int n;
    printf("\nEnter The Value : ");
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("\n%d is even number",n);
    }
    else
    {
        printf("\n%d is odd number",n);
    }
    return 0;
}
 
To download raw file Click Here

Output

Enter The Value : 23
23 is odd number

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