You are on page 1of 3

WPP PRACTICAL LIST – 2 SOLUTION

WPP Practical List – 2 Solution


1) Write a program to create different variables and display its values
using echo statement
<?php
$no = 10;
$ch = 'A';
$pi = 3.14;
$name = "BSPP";
echo "Value of no = $no <br>";
echo "Value of pi = ".$pi;
echo "<br> value of ch = $ch <br>";
echo "College name = $name <br>";
?>
2) Write a program to perform different arithmetic operations.
<?php
$a = 10;
$b = 5;

$add = $a + $b;
$sub = $a - $b;
$mul = $a * $b;
$div = $a / $b;

echo "Addition = $add";


echo "<br> Substration = $sub";
echo "<br> Multiplication = $mul";
echo "<br> Division = $div";
?>
3) Write a program to count average of five numbers.
<?php
$n1 = 10;
$n2 = 12;
$n3 = 56;
$n4 = 3;
$n5 = 43;

WPP PRACTICAL LIST – 2 SOLUTION BY: G D PARMAR


WPP PRACTICAL LIST – 2 SOLUTION

$avg = ($n1+$n2+$n3+$n4+$n5)/5;
echo "Average = $avg";
?>
4) Write a program to convert temperature value from Celsius to
Fahrenheit.
<?php
$c = 50;
$f = (1.8*$c)+32;
echo "$c degree Celsius = $f Fahrenheit";
?>
5) Write a program to find area of square
<?php
$a = 5;
$area = $a * $a;
echo "Area of square = $area";
?>
6) Write a program to find area of circle. (Take PI as a constant)
<?php
define("PI",3.14);
$r = 10;
$area = PI*$r*$r;
echo "Area of circle = $area";
?>
7) Write a program to merge two string values using echo statement.
<?php
$u = "Ganpat University, ";
$clg = "B S Patel Polytechnic.";
echo $u.$clg;
?>
8) Write a program to create three constant variables and display its
values using echo statement
<?php
define("PI",3.14);
define("CAR","Maruti");
WPP PRACTICAL LIST – 2 SOLUTION BY: G D PARMAR
WPP PRACTICAL LIST – 2 SOLUTION

define("A",10);
echo PI;
echo "<br>";
echo CAR;
echo "<br>";
echo A;
?>

WPP PRACTICAL LIST – 2 SOLUTION BY: G D PARMAR

You might also like