C Programming Code Examples C > Functions Code Examples C program to check even or odd using functions C program to check even or odd using functions Write a C program to input a number from user and check whether given number is even or odd using functions. How to check even or odd using functions in C programming. Declare function to find even odd First give a meaningful name to our function, say isEven(). Next, the function must accept one integer which is to be validated for even condition, say isEven(int num). Finally as per name, the function must return true if given integer is even otherwise false. However, C does not supports boolean values. In C programming, 0 is represented as false and 1 (any non-zero integer) as true. Hence, isEven() we must return an integer from function. So the function declaration to check even number is int isEven(int num); #include <stdio.h> /** * Function to check even or odd * Returns 1 is num is even otherwise 0 */ int isEven(int num) { return !(num & 1); } int main() { int num; /* Input number from user */ printf("Enter any number: "); scanf("%d", &num); /* If isEven() function returns 0 then the number is even */ if(isEven(num)) { printf("The number is even."); } else { printf("The number is odd."); } return 0; }