goldenashok
Pages
Home
Php Tutorial
Jquery
Contact
Wednesday, 25 March 2015
Find out given number even or odd without using mod operator ?
<?
$a = 47;
$b = $a/2;
if(!strpos($b,'.'))
{
echo 'even';
}else
{
echo 'odd';
}
?>
(or)
<?
$num = 13;
if($num&1){echo 'odd';}else{echo 'even';}
?>
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment