Content Beyond
Content Beyond
PROCEDURE:
PROGRAM:
<html>
<body>
<form method="post">
Enter a number:
<input type="number" name="number">
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if($_POST){
$number = $_POST['number'];
//divide entered number by 2
//if the reminder is 0 then the number is even otherwise the number is odd
if(($number % 2) == 0){
echo "$number is an Even number";
}else{
echo "$number is Odd number";
}
}
?>
Marks Marks
S.No Description
Allotted Obtained
1 Aim 1
2 Program 3
3 Execution 2
4 Output 2
5 Viva-Voce 2
Total 10
RESULT:
EXERCISE-2 DATE:
PRIME NUMBERS
AIM:
To write a PHP code to find the given number is prime or not.
PROCEDURE:
PROGRAM:
<form method="post">
Enter a Number: <input type="text" name="input"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
if($_POST)
{
$input=$_POST['input'];
for ($i = 2; $i <= $input-1; $i++) {
if ($input % $i == 0) {
$value= True;
}
}
if (isset($value) && $value) {
echo 'The Number '. $input . ' is not prime';
} else {
echo 'The Number '. $input . ' is prime';
}
}
?>
Marks Marks
S.No Description
Allotted Obtained
1 Aim 1
2 Program 3
3 Execution 2
4 Output 2
5 Viva-Voce 2
Total 10
Result: