Write program is to check whether the number provided by the user is even or odd.
As you aware that even numbers are completely divisible by zero i;e
they leave remainder zero when divided by two.
On the other hand, odd numbers are not completely divisible by two. So,
we can make use of the remainder operator(%) in c to check whether a number is odd or even.
C program to check if number is odd or even - Source code
Program Output
Program Explanation
Modulus operator in C programming language, denoted by %, returns the remainder after the division operation. Here we have perform the modulus operator on the number provided by the user and checked whether it is equal to zero(n%2 == 0). The if statement is executed automatically if the expression inside it returns true value. Otherwise, the else statement is executed.