Showing posts with label php program to check whether a number is positive or negative. Show all posts
Showing posts with label php program to check whether a number is positive or negative. Show all posts

Sunday, May 5, 2024

php program to check whether a number is positive or negative

Check whether a number 

php program to check whether a number is positive or negative

Q. program to check whether a number is positive or negative or Zero 

Example ::-

<?php

$no=49;
$result=($no>0)? "positive no":"Negative no" ;
echo $result;

?>

 output ::-

positive no 


Q. php program to check whether a number is positive or negative or Zero 

Form.  

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="
width=device-width, initial-scale=1.0">
    <link rel ="stylesheet" href="
css/bootstrap.css">
    <title>Document</title>
</head>
<body class="bg-primary">
<div class="bg-white col-md-4 mx-auto mt-5 p-3">
<h5>positive/negative /zero</h5>
    <form action="accept-posi-nega-no.php"
method="get">
    <label>enter any no</label>    
    <input type="number" name="no" class="
form-control" required>
    <input type="submit" value="check" name="b1"
class="btn-btn-primary mt-2">

    </form>
    <?php
        if(isset($_GET['b1']))
        {
            $number=$_GET['no'];
       
        if($number>0)
        {
            echo"positive no";
        }
        else if ($number<0)
        {
            echo"negative";
        }
        else
        {
            echo "no is zero";
        }
    }


       
    ?>
    </div>
</body>
</html>


 php program to check whether a number is positive or negative or Zero 

Form . 

Output :--


Read More:::-

how to run php program

php introduction

php data type

php comparison operators

php logical operators

php array type