0% found this document useful (0 votes)
33 views7 pages

PHP Programming Exercises

The document contains the name, roll number, class, subject, and date of a student submission. It then provides 5 PHP programs: 1) A loop to count from 5 to 15, 2) Printing two variables in an echo statement, 3) Checking student grade based on marks, 4) Using a switch to print the day of the week, 5) Calculating a factorial using a for loop.

Uploaded by

Aysha Reshma
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)
33 views7 pages

PHP Programming Exercises

The document contains the name, roll number, class, subject, and date of a student submission. It then provides 5 PHP programs: 1) A loop to count from 5 to 15, 2) Printing two variables in an echo statement, 3) Checking student grade based on marks, 4) Using a switch to print the day of the week, 5) Calculating a factorial using a for loop.

Uploaded by

Aysha Reshma
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

Name: Aysha Reshma.

M
Roll Number: 21BCC010
Class: 2nd BSC CSA
Subject: Programming in PHP
Topic: Simulation
Date of Submission:10.04.2023
[Link] a program to count 5 to 15 using PHP loop
Program:
<?php
$message_1 = "Good Morning.";
$message_2 = "Have a nice day!";
echo $message_1." ". $message_2;
?>

2. Write a program to print two variables in single echo


Program:

<?php
echo "Abinaya J.S 21BCC001 \n";
$a="Good Morning ";
$b="Have a nice day!";
echo $a.$b;

?>
3. Write a program to check student grade based on
Marks
Program:
<?php
echo "Abinaya J.S 21BCC001 \n";
$a=(int)readline("Enter your Score:");
if ($a>=60)
echo "First Division";
elseif ($a>=45 && $a<=59)
echo "Second Division";
elseif ($a>=33 && $a<=44)
echo "Third Division";
elseif ($a>33)
echo "Fail";
?>

4. Write a program to show day of the week using


Switch
Program:
<?php
echo "Abinaya J.S 21BCC001 \n";
$n=(int)readline("Enter number weekend: ");
switch($n)
{
case 1:
echo "Monday";
break;
case 2:
echo "Tuesday";
break;
case 3:
echo "Wednesday";
break;
case 4:
echo "Thrusday";
break;
case 5:
echo "Friday";
break;
case 6:
echo "Saturday";
break;
case 7:
echo "Sunday";
break;
default:
echo"Invalid Number";

?>
5. Write a factorial program using for loop in php
Program:
<?php
$num = 3;
$factorial = 1;
for ($x=$num; $x>=1; $x--)
{
$factorial = $factorial * $x;
}

echo "The factorial of $num is $factorial";


?>

You might also like