JavaScript program to calculate circle area

Views: 136   

Following program shows you how to calculate circle area.
In this tutorial will get circle radius from user and calculate area and prints it using following formula
Area = PI X r X r

var circleRadius = parseInt(prompt("Please enter the radius of circle:"));
var areaOfCircle = Math.PI * (circleRadius * circleRadius);
console.log("Area of circle is: " + areaOfCircle);

Output:

Please enter the radius of circle:
4
Area of circle is: 50.26548245743669
On By