# C Program to Check Whether a Number is Even or Odd

C program to check a number is even or odd; In this tutorial, i am going to show you how to find a number is even or odd in the c program using function, modules operator, and ternary operator.

## Algorithm and Programs to Check Whether a Number is Even or Odd in C

• Algorithm to Check Whether a Number is Even or Odd
• C Program to Check Even or Odd
• C Program to Check Whether a Number is Even or Odd using Function
• C Program to Check Whether a Number is Even or Odd using Ternary Operator

### Algorithm to Check Whether a Number is Even or Odd

Follow the following algorithm to write a program to check whether a number is even or odd:

• Step 1: Start Program
• Step 2: Read the number from user and store it in a.
• Step 3: Find the number is even or odd using a % 2 == 0.
• Step 4: Print number is even or odd
• Step 5: Stop Program

### C Program to Check Even or Odd

```#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
// true if num is perfectly divisible by 2
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);

return 0;
}```

The result of the above c program; as follows:

```Enter an integer: 10
10 is even.```

### C Program to Check Whether a Number is Even or Odd using Function

```#include <stdio.h>
#include <stdlib.h>
int find_Num(int);//function prototype
int main()
{
int num;
printf("Enter a number to check odd or even :- ");
scanf("%d",&num);
find_Num(num);//calling the function
return 0;
}
//create function
int find_Num(int num){//function definition
if(num%2==0){
printf("\n%d is an even number",num);
}
else{
printf("\n%d is an odd number",num);
}
}```

The result of the above c program; as follows:

```Enter a number to check odd or even :- 11
11 is an odd number```

### C Program to Check Whether a Number is Even or Odd using Ternary Operator

```#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);

(num % 2 == 0) ? printf("%d is even.", num) : printf("%d is odd.", num);
return 0;
}```

The result of the above c program; as follows:

```Enter an integer: 15
15 is odd.```