Skip to main content

Odd or Even Using Function in C

1 min read Updated June 30, 2026
Share:
On this page (6sections)

About this program

This is an example program in c calculation programs. Read the concept first: Data Types in C Programming, then study the code and output below.

Definition

A formal definition of an even number is that it is an integer of the form n = 2k, where k is an integer;[3] it can then be shown that an odd number is an integer of the form n = 2k + 1.

Odd Or Even Example Program Using Functions

/*##Check if an integer is odd or even*/
/*##Calculation Programs, Datatype Programs, Basic Programs*/

#include <stdio.h>

char* odd_even(int i);

int main()
{
   int number;

   printf("Enter an integer : ");
   scanf("%d", &number);

   printf("Result : %s",odd_even(number));
   return 0;
}

char* odd_even(int number)
{
  if (number%2 == 0){
      return "YOUR NUMBER IS EVEN NUMBER";
   }else{
      return "YOUR NUMBER IS ODD NUMBER";
   }
}

Sample Output

Enter an integer : 5
YOUR NUMBER IS ODD NUMBER

Enter an integer : 6
YOUR NUMBER IS EVEN NUMBER

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C program do?
It is a C example program that demonstrates Odd or Even Using Function, including the complete source code and the expected sample output.
How do I compile and run this C program?
Save the code in a `.c` file, compile it with `gcc filename.c -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses conditional logic and reading user input, illustrating a common pattern in C programming.

Related Tutorials

Search tutorials