PHP

PHP Program to Check Whether a Number is Even or Odd2 min read

Write a PHP program to check whether a number is even or odd using if else. How to check whether a number is even or odd using if else in PHP program. PHP Program to input a number from user and check whether the given number is even or odd. Logic to check even and odd number using if...else in PHP programming.

Output:

PHP Program to Check Whether a Number is Even or Odd

PHP Program to Check Whether a Number is Even or Odd

Code:




A number exactly divisible by 2 leaving no remainder, is known as even number. Programmatically, if any number modulo divided by 2 equals to 0 then, the number is even otherwise odd.

Step by step descriptive logic to check whether a number is even or odd.

Input a number from user. Store it in some variable say num.
Check if number modulo division equal to 0 or not i.e. if(num % 2 == 0) then the number is even otherwise odd.

Leave a Comment