Programming Code Examples

Calculating the Surface Area and Volume of a Cylinder in PHP1 min read

PHP program that accepts the dimensions of a cylinder and prints its surface area and volume:

In this program, the surfaceArea function calculates the surface area of a cylinder given its $radius and $height. The volume function calculates the volume of a cylinder given its $radius and $height.

The program prompts the user to enter the radius and height of the cylinder using the readline function. It then calls the surfaceArea and volume functions and assigns the results to variables $surfaceArea and $volume. Finally, it prints the surface area and volume of the cylinder to the screen.

Add comment