Thursday 11 February 2016

Even Numbers in a Range

Code:

<!DOCTYPE html>
<html>
<body>
<center>
    <h1>EVEN NUMBERS IN RANGE</h1>
<?php
if(isset($_POST['find']))
{
$a=$_POST['lower'];
$b=$_POST['upper'];
for($a;$a<=$b;$a++)
    {
    if($a%2==0){
        echo "$a<br/>";
        }
    }
}
?>
<form method="post" action="index.php" name="evn">
    Lower limit: <input type="text" name="lower">
    Upper limit: <input type="text" name="upper">
    <input type="submit" name="find" value="Find">
</form>
</center>
</body>
</html>

Output:

No comments:

Post a Comment