You are on page 1of 1

PHP Work

NOTE: It is a classwork to be done in Group on Friday 02/06/2023 Evening.


1. Write a PHP script to swap two numbers ($a=6, $b=8) using a third variable
$c.
2. Write a PHP script to calculate the area of a triangle.
3. Write a PHP script for simple calculator by using $a=6, $b=8, $operator and
$result. $result will store and display the answer (sum, product, difference,
quotient, and modulus) depending on the given operator.
4. Write a PHP script to display all even numbers between 11 and 50.
5. Write a PHP script to add and display the sum of all odd numbers from 7 to 1.
6. Write a PHP script to display the square of numbers from 1 to 10.
7. Complete:
Example1 Example2
X=3; X=3;
A=++X; A=X++;
// A contains …, X contains … //A contains …, X contains ….

8. Write a PHP script to add module marks of a student: CAT1(/20),


CAT2(/20), ASSIGNMENT(/20), EXAM (/20); calculate the average and
display the decision as follows:
Average 16 and above: Excellent
Average 14-16: very good
Average 12-14: good
Average below 12: fail

9. Using switch case write a write a PHP script with $word. If $word
contains T it displays “ you are teacher”, if S it displays” you are student”, if
G it displays “ you are a Guard”, otherwise “ you are visitor”.
10.Write a PHP script to display your age depending on the year of birth you
give.
11.Evaluate the following expression: $a= 7,$b=5; $c =($a<$b)?$a:$b; What
will be the value of $c?
12.Write a PHP script to display multiplication table of 7.

Page 1 of 1

You might also like