Skip to content
Home » Even Odd Program in C using function

Even Odd Program in C using function

Learn about Even Odd Program in C using function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Even Odd Program in C using function

The below program checks whether the given number is Even or odd using a user-defined function. The input is taken from the user and the result get displayed.

Program:

 #include<stdio.h>
 void checkOddEven(int number)
 {
   if(number%2 == 0)
   printf("%d is an even number \n", number);
   else
   printf("%d is an odd number \n", number);
 }
 int main()
 {
     int number;
     printf("Enter number: ");
     scanf("%d",&number);
     
     checkOddEven(number);
     
     return 0;
 }

Output:

Enter number: 9
9 is an odd number

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Even Odd Program in C Using for loop
Even Odd Program in C Using the Conditional Operator