Thanks to visit codestin.com
Credit goes to www.scribd.com

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

22203a0063 Prac 1,2,3

This document outlines a PHP laboratory course for Computer Engineering students, detailing various experiments and programming tasks. Students are required to install PHP, create programs demonstrating basic functions, decision-making structures, and looping structures, as well as manage and analyze student grades. The document includes example code for tasks such as grade calculation, Fibonacci series generation, and prime number checking.

Uploaded by

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

22203a0063 Prac 1,2,3

This document outlines a PHP laboratory course for Computer Engineering students, detailing various experiments and programming tasks. Students are required to install PHP, create programs demonstrating basic functions, decision-making structures, and looping structures, as well as manage and analyze student grades. The document includes example code for tasks such as grade calculation, Fibonacci series generation, and prime number checking.

Uploaded by

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

DEPARTMENT OF COMPUTER ENGINEERING

Subject: PHP Subject Code:22619

Semester:6 Semester
th Course: Computer Engineering

Laboratory No: L001A Name of Subject Teacher: Prof. Sneha Patange

Name of Student: Arya Pawar Roll Id: 22203A0063

Experiment Title of Experiment Application


No:

1 a. Install and configure PHP, web A) Write a Phpimplement


server, MYSQL basic php
b. Write a program to print “Welcome functions(echo,print,
to PHP” var_dump())
c. Write a simple PHP program using B) STUDENT GRADE
expressions and operators. CALCULATOR-
2 Write a PHP program to demonstrate Create a script to manage and
the use of Decision making analyse for a class. The script
control structures using- should achieve the following
a. If statement obectives:
b. If-else statement 1. Input Grades: Assume grades
c. Switch statement are integers ranging from 0 to 100
3 Write a PHP program to demonstrate 2. Grade Classification:
the use of Looping structures Classification done on following
using- categories
a) While statement A. 85% to 100%
b) Do-while statement Β. 70% to 85%
c) For statement C-50% to 70%
d) Foreach statement D-45% to 50%
Fail below 45%
Generate a summary report once
the input is complete, and save it
into a text file which should
include:
1. Total number of students
2. Number of students in each
grade category
3. The class average
4. The highest and lowest grades
C) Write PHP programs to
implement for loop to print
fibonaaci series and prime number
X.PROGRAM CODE
1.Write a program to use echo , print, var_dump

<?php

$username = "Arya";

$surname = "Pawar";

$rollno = "22203A0063";

echo "hello " . $username . $surname . "\n";

echo print("hello " . $username . $surname) . "\n";

var_dump($username);

var_dump($rollno);

echo "Rollno = $rollno\n";

$arr = array(20, 30, 70, 60);

var_dump($arr);

print_r($arr);

?>

OUTPUT
2. Write a program to enter marks of student and display grade for one sttudent

3. Write a program to take marks from user using readline


4. Write a program, use do while, while and store it in file

5. Add summary report in above program and store it in file


<?php

$file = fopen("data.txt", "w");

fwrite($file, "Rollno\tName\tPercentage\tGrade\n");

$totalStudents = 0;

$totalMarks = 0;

$highestMarks = 0;

$lowestMarks = 100;

$gradeCount = ['A' => 0, 'B' => 0, 'C' => 0, 'F' => 0];

do {

$rollno = readline("Enter your roll no: ");

$per = readline("Enter your percentage: ");

$name = readline("Enter your name: ");

if ($per >= 80 && $per <= 100) {

$grade = "A";

} elseif ($per >= 60 && $per < 80) {

$grade = "B";
} elseif ($per >= 40 && $per < 60) {

$grade = "C";

} else {

$grade = "F";

$data = "$rollno\t$name\t$per\t$grade\n";

fwrite($file, $data);

$totalStudents++;

$totalMarks = $totalMarks + $per;

if ($per > $highestMarks) {

$highestMarks = $per;

if ($per < $lowestMarks) {

$lowestMarks = $per;

$gradeCount[$grade]++;

$yon = readline("Do you want to continue (Y/N): ");

while ($yon == "Y" || $yon == "y");

fclose($file);

echo "\nData saved successfully.\n";

if ($totalStudents > 0) {

echo "Total Students: $totalStudents\n";

echo "Average Marks: " . ($totalMarks / $totalStudents) . "\n";

echo "Highest Marks: $highestMarks\n";


echo "Lowest Marks: $lowestMarks\n";

echo "Grade-wise Count:\n";

foreach ($gradeCount as $grade => $count) {

echo "$grade: $count\n";

?>
6. Write a program to write Fibonacci series using for loop

<?php

$limit = readline("Enter the number: ");

$a = 0;

$b = 1;

echo "Fibonacci Series: $a $b ";

for ($i = 2; $i < $limit; $i++) {

$c = $a + $b;

$a = $b;

$b = $c;

echo "$c ";

?>

7. Write a program to check no is prime or not using for loop

<?php
$number = (int) readline("Enter a number: ");
$isPrime = true;
if ($number <= 1) {
$isPrime = false;
}
for ($i = 2; $i < $number; $i++) {
if ($number % $i == 0) {
$isPrime = false;
break;
}
}
echo "$number is " . ($isPrime ? "prime" : "not prime") . "\n";
?>

You might also like