Tuesday, January 22, 2013

Find Odd And Even Number in Php

Find Odd Or Even Number using php Script.Here two way to find this solution just see the below php script.

First : Modulo Operator (%)

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

Second Way :Bitwise Operator '&'
$num=9;
if($num&1)
{
echo "Odd"; 
}
else
{
echo "Even"; 
}

No comments:

Post a Comment

Thanks....