top of page
Writer's pictureThe Tech Platform

Write a program to find the Area, Diameter and Circumference of Circle in PHP


Code:

<?php
$r = 4;
$d = NULL;
$c = NULL;
$a = NULL;

// $r = radius
// $d = diameter
// $c = circumference
// $a = area

/* formulas for the area, diameter and circumference of circle */
$d = 2 * $r;
$c = 2 * 3.14 * $r;
$a = 3.14 * ($r * $r);

echo "When the radius of circle is 4:";
echo "<br>";
echo "<br>";
echo "\n Diameter of Circle      = " . $d . " units" ; 
echo "<br>";
echo "\nCircumference of circle  = " . $c . " units";
echo "<br>";
echo "\nArea of Circle          = " . $a . " sq. units";

?>

Output:


The Tech Platform

0 comments

Comments


bottom of page