Even Odd number Program

Even Odd number Program

Even Odd number Program in PHP

Even Odd number Program:- In this tutorial, I am going to explain how you can make a program to find a number is even or odd. Ever number are those which is divisible by 2 and odd numbers are not divisible by 2.

For Example, 20 is divisible by 2 so it is even number.

The main logic behind to find Even/ Odd of the given number is to first store the given number in a variable, say the number. Then divide the given number by 2 using (%) Modulus Operator, also known as Remainder Operator i.e., This Operator is used to find the Remainder of two numbers. For e.g. 10 % 4 = 2, 10 % 2= 0, 10 % 3 = 1, etc.

Using If Statements Check the number is divisible by 2, through Modulus Operator i.e if Remainder is 0 then number is completely divisible by 2 and Hence Echo or Print the Statement i.e the Given number is EVEN, Otherwise Print Given Number is ODD.

Even Odd number Program in PHP

<?php

$number=20;

if($num%2==0)
{
 echo "Even number"; 
}
else
{
 echo "Odd number";
} 

?>

Output of Even Odd number Program

	
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php

Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php

Leave a Comment