12th C a Practical Exam EM 2025
12th C a Practical Exam EM 2025
NAME :
REG.NO :
STD :
SUBJECT :
n
l.i
DATE :
SESSION :
BATCH :
da
ka
vi
al
.k
w
w
w
QUESTION - 1
Program: 6
Write a PHP script that stores a value in a variable and then checks if it is less than,
equal to or greater than 5 ?
AIM:
To check if a variable is less than, equal to, or greater than 5 and output the corresponding
message.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take p2.php for an example.
4. Save the file p2.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
6. Go to the browser and type:-http://localhost/p2.php In your web browser, you should see
n
the results of your script.
l.i
PHP SCRIPT:
<?php
$num = 10;
if ($num< 5)
{ da
ka
echo “The number is less than 5.”;
}
elseif ($num> 5)
vi
{
echo “The number is greater than 5.”;
al
}
else
.k
{
echo “The number is equal to 5.”;
w
}
?>
w
OUTPUT:
The number is greater than 5.
w
RESULT:
The expected output is achieved.
[OR]
PREPARED BY..., B.MOHAMED YOUSUF M.C.A., B.Ed.., (PG ASST IN COMPUTER SCIENCE)
QUESTION - 2
Program: 7
Write a PHP script that takes a number and outputs the corresponding text for the
number using switch statement.
AIM:
To output the corresponding text for a number using a switch statement.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take p3.php for an example.
4. Save the file p3.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
6. Go to the browser and type:-http://localhost/p3.php In your web browser, you should see
the results of your script.
n
PHP SCRIPT:
l.i
<?php
$num = 3;
switch ($num)
{
case 1: da
ka
echo “One”;
break;
case 2:
vi
echo “Two”;
break;
al
case 3:
echo “Three”;
.k
break;
case 4:
w
echo “Four”;
break;
w
case 5:
echo “Five”;
w
break;
default:
echo “Number is not between 1 to 5.”;
break;
}
?>
OUTPUT:
Three
RESULT:
The expected output is achieved.
[OR]
Program: 2 [ CREATING NOTICE BOARD ]
QUESTION - 3
Program: 8
Write a PHP script to print 1 to 10 number in separate line using while loop.
AIM:
To print the numbers from 1 to 10 on separate lines using a while loop.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take p4.php for an example.
4. Save the file p4.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
6. Go to the browser and type:-http://localhost/p4.php In your web browser, you should see
the results of your script.
n
PHP SCRIPT:
l.i
<?php
$number = 1;
while ($number <= 10)
{
echo “$number <br>”; da
ka
$number++;
}
?>
vi
OUTPUT:
1
al
2
3
.k
4
5
w
6
7
w
8
9
w
10
RESULT:
The expected output is achieved.
[OR]
PREPARED BY..., B.MOHAMED YOUSUF M.C.A., B.Ed.., (PG ASST IN COMPUTER SCIENCE)
QUESTION - 4
Program: 9
Write a PHP script that calculates the sum and product of the numbers from 1 to 10 using for
loop.
AIM:
To write a PHP script that calculates the sum and product of the numbers from 1 to 10
using for loop.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take p5.php for an example.
4. Save the file p5.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
n
6. Go to the browser and type:-http://localhost/p5.php In your web browser, you should see
l.i
the results of your script.
PHP SCRIPT:
<?php
$sum = 0;
$product = 1; da
ka
for ($i = 1; $i<= 10; $i++)
{
$sum += $i;
vi
$product *= $i;
}
al
?>
OUTPUT:
w
RESULT:
The expected output is achieved.
w
[OR]
PREPARED BY..., B.MOHAMED YOUSUF M.C.A., B.Ed.., (PG ASST IN COMPUTER SCIENCE)
QUESTION - 5
Program: 10
Write a PHP script that loops through an array of names, prints each name and its
length, and counts the total number of names using ‘foreach’.
AIM:
To use a foreach loop to iterate through an array in PHP and access its elements.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take p6.php for an example.
4. Save the file p6.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
n
6. Go to the browser and type:-http://localhost/p6.php In your web browser, you should see
l.i
the results of your script.
PHP SCRIPT:
<?php
da
$names = array(‘Ram’, ‘Ravi’, ‘Kumar’, ‘Barath’, ‘Lavanya’);
foreach ($names as $name)
ka
{
echo “Name: $name<br>”;
echo “Length: “ . strlen($name) . “<br><br>”;
vi
}
$count = count($names);
al
OUTPUT:
Name: Ram
w
Length: 3
w
Name: Ravi
Length: 4
w
Name: Kumar
Length: 5
Name: Barath
Length: 6
Name: Lavanya
Length: 7
AIM:
To perform various arithmetic operations on two variables and output the results.
PROCEDURE:
1. Open a new file in your text editor (Notepad).
2. Type the following PHP script.
3. Save the file in the following format “filename.php”. Let us take pl.php for an example.
4. Save the file pl.php in the file saving path - c:\wamp64\www\
5. Make sure Apache is started in Wampserver.
6. Go to the browser and type:- http://localhost/pl.php In your web browser, you should see
the results of your script.
n
PHP SCRIPT:
l.i
<?php
$num1 = 10;
$num2 = 5;
$sum = $num1 + $num2;
$sub= $num1 - $num2; da
ka
$mul = $num1 * $num2;
$div = $num1 / $num2;
$mod = $num1 % $num2;
vi
OUTPUT:
The sum of 10 and 5 is: 15
w
PREPARED BY..., B.MOHAMED YOUSUF M.C.A., B.Ed.., (PG ASST IN COMPUTER SCIENCE)