Odd or Even in C

In this example, you will learn to check whether a number entered by the user is even or odd using if statement. The even numbers are those which when divided by 2 remainder of 0 and Odd numbers are those numbers which when divided by 2 remainder of 1.

The if statement is used to route program execution through two different paths. The if statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. The if statement is written with the if keyword, followed by a condition in parentheses, with the code to be executed in between curly brackets.

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)
int main()
    int n;
    printf("\nEnter The Value : ");
        printf("\n%d is even number",n);
        printf("\n%d is odd number",n);
    return 0;
To download raw file Click Here


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