PHP Practical Slip 2 Q.B

Write a PHP Script to display the surface area and volume of a cuboid. (Hint: surface area=2(lb+lh+bh ), volume = lbh ).

<?php
// Define length, breadth, and height
$length = 5;
$breadth = 3;
$height = 4;

// Calculate Surface Area
$surface_area = 2 * (($length * $breadth) + ($length * $height) + ($breadth * $height));

// Calculate Volume
$volume = $length * $breadth * $height;

// Display Results
echo "Length: " . $length . "<br>";
echo "Breadth: " . $breadth . "<br>";
echo "Height: " . $height . "<br><br>";

echo "Surface Area of Cuboid: " . $surface_area . "<br>";
echo "Volume of Cuboid: " . $volume;
?>
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top