Showing posts with label even number. Show all posts
Showing posts with label even number. Show all posts

Thursday, 6 June 2013

check odd or even number in php

Even number can be devided by 2, All Even numbers always end with a digit of 0, 2, 4, 6 or 8. 2, 14, 16, 30 etc.

Odd number can not be devided by 2, All Odd numbers always end with a digit of 1, 3, 5, 7, or 9 2, 8, 16, 30 etc.

<?php
     $number = 13; // input number
     if($number%2 == 0){
          echo "$number is even number";
     }else{
          echo "$number is odd number";
     }
?>
Output is:
13 is odd number