Odd or Even Example in C
On this page (5sections)
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
/*##Check if an integer is odd or even*/
/*##Calculation Programs, Datatype Programs, Basic Programs*/
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer : ");
scanf("%d", &number);
if (number%2 == 0){
printf("The number you entered is an EVEN number");
}else{
printf("The number you entered is an ODD number");
}
return 0;
}
Sample Output
Enter an integer : 4
The number you entered is an EVEN number
Related Pages
Learn the concept first, then study the code:
- C Programs — Browse all C Programs.
- Data Types in C Programming — Concept — int, float, double and format specifiers.
- Area Of Circle Example C Program — More in c calculation programs.
- Area Of Square Example C Program — More in c calculation programs.