Odd or Even Program in C Using Function

Odd or even program in c using function for beginners to understand the function concepts to check the number is odd or even program in a c programming language.

Odd or Even Program in C Using Function

A number that can be divided into two equal groups is called an even number. 

A number that cannot be divided into two equal groups is called an odd number. 

Even numbers, regardless of how many digits they have, end in 2, 4, 6, 8, and zero.

Function Definition in C

A function is a collection of statements that work together to complete a task. Every C program has at least one function, main(), and even the simplest programs can define more functions. 

The name, return type, and parameters of a function are all specified in a function declaration.

Functions are used to perform repetitive tasks, or we can say that functions are those that allow us to improve the efficiency of a program by allowing us to create functions that contain a set of repetitive instructions, or we need them in a program at various places.

#include <stdio.h>
int isEven(int num)
{
return !(num & 1);
}
int main()
{
int num;
printf("Enter The Number");
scanf("%d", &num);
if(isEven(num))
{
printf("Number is Even");
}
else
{
printf("Number is Odd");
}
return 0;
}

Output:

Enter The Number 45
Number is Odd