We check the number is even or odd by using 'if else statement'.
An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24
An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15
Write a program to check wheather number is Even or Odd :-
//Program to Check Even or Odd
void find(int n);
printf("Enter any number:");
void find(int n)
//True if the number is perfectly divisible by 2
printf("Number is Even");
printf("Number is Odd");
Enter any number:1258
Number is Even
1. In the program, integer entered by the user is stored in variable number.
2. Then, whether the number is perfectly divisible by 2 or not is check.
3. If the number is perfectly divisible by 2, test expression number%2 == 0 evaluates to 1 (true) and the number is even.
4. However, if the test expression evaluates to 0 (false), the number is odd.