loader image

JavaScript program to find the area of a circle

Aim: Write a JavaScript program to perform find the area of a circle.

<html>

<body>
    <h1>Area and circumference of a circle</h1>
    Enter the radius for your circle:
    <input type="text" id="txtRadius" />
    <input type="button" value="Calculate" onClick=CalculateArea() />

    <script>
        function CalculateArea() {
            var radius = document.getElementById('txtRadius').value;
            alert("The area of the circle is " + (radius * radius * Math.PI));
        }
    </script>
</body>

</html>
Output
area and circumference of a circle js
area and circumference of a circle js example 2
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top