0% found this document useful (0 votes)
39 views4 pages

Content Beyond

The document describes two PHP programs: 1) a program that takes a number as input and determines if it is odd or even, and 2) a program that takes a number as input and determines if it is a prime number. It provides the code for each program and steps for running the programs.

Uploaded by

moodman0903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

Content Beyond

The document describes two PHP programs: 1) a program that takes a number as input and determines if it is odd or even, and 2) a program that takes a number as input and determines if it is a prime number. It provides the code for each program and steps for running the programs.

Uploaded by

moodman0903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

EXERCISE-1 DATE:

ODD OR EVEN NUMBER


AIM:
To write a PHP code to find the given number is odd or even.

PROCEDURE:

Step 1: Download WAMP SERVER (32BIT) v3.0.6 and save it my drive.


Step 2: Run the WAMP SERVER v3.0.6 and start all services
Step 3: Open the notepad++ available in the window desktop.
Step 4: Start the program write the code on the notepad++ editor.
Step 5: Save the program WWW directory in WAMP server
Step 6: Open Google chrome and type http://localhost:/file name in Address bar.
Step 7: Run the program

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:

Step 1: Download WAMP SERVER (32BIT) v3.0.6 and save it my drive.


Step 2: Run the WAMP SERVER v3.0.6 and start all services
Step 3: Open the notepad++ available in the window desktop.
Step 4: Start the program write the code on the notepad++ editor.
Step 5: Save the program WWW directory in WAMP server
Step 6: Open Google chrome and type http://localhost:/file name in Address bar.
Step 7: Run the program

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:

You might also like