Finding odd or even numbers using PHP

GOCOURSE

Find odd or even number normal method 

Program:

<?php
$num = 7;
if($num % 2 == 0)
{
    echo $num . " is even.";
else 
{
    echo $num . " is odd.";
}
?>

Output:

7 is odd.

Find odd or even number "Input"method 

Program:

<?php
$num = readline("Enter a number: ");
if($num % 2 == 0)
{
    echo $num . " is even.";
else 
{
    echo $num . " is odd.";
}
?>

Output:

Enter a number: 10
10 is even.
Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send