Write a PHP program to check whether a number is positive, negative or zero
Description:
Write a PHP program to check whether a number is positive, negative or zero.
Instructions:
- You can use if else conditions.
- You should use appropriate PHP Operators.
- Also check if it not a numeric value.
View Solution/Program
<?php
$number = 324; // enter any number of your choice here
if ($number > 0) // condition for positive numbers
{
echo $number . " is a positive number";
} else if ($number < 0) // condition for negative number
{
echo $number . " is a negative number ";
} else if ($number == 0) // condition for zero
{
echo "You have entered zero";
} else {
echo " please enter a numeric value";
}
?>
Tutorials Class - Output Window
324 is a positive number
Learn more about the similar topics:
Tutorials |
---|
No Content Found. |
Exercises & Assignments |
---|
Write a PHP program to check whether a number is positive, negative or zero |
Interview Questions & Answers |
---|
No Content Found. |