This post contains a total of 9+ JavaScript Program Examples with Source Code to Calculate the Area of a Circle. All these Circle Area Calculator programs are made using JavaScript.
You can use the source code of these examples with credits to the original owner.
Related Posts
JavaScript Programs to Calculate Area of Circle
1. By LynTon
Made by LynTon. Simple Circle Area Calculator. Source

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style>
body {
text-align: center;
background-color: #AAFFFF;
}
#heading {
text-decoration: underline;
}
</style>
</head>
<body>
<h1 id="heading">Circle Area Calculator</h1>
<input id="radius" type="number" name="radius" placeholder="Enter radius here...">
<input type="button" onclick="calculate()" value="Calculate area">
<p>Area: <span id="area">???</span></p>
<script>
function calculate() {
let r = Number(document.getElementById("radius").value);
document.getElementById("area").textContent = `${(Math.PI * (r * r)).toFixed(2)} (2dp)`;
}
</script>
</body>
</html>
2. By Manual
Made by Manual. JavaScript Program to Find the Area of a Circle, it uses the Prompt to take input. Source
10 The area of the circle is 314
function circleArea(r){
return radius = 3.14*(r*r)
}
var r =prompt("What is the radius of your circle?'");
document.write("The area of the circle is "+ circleArea(r));
console.log("Area =" +circleArea(r));
3. By Sharvil Khot
Made by Sharvil Khot. Source
21 Area of the circle is 1384.74
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/Javascript">
var r,area
r=prompt("Enter the radius")
area=3.14*r*r
document.write("<h1>")
document.write("Area of the circle is " +area);
</script>
</body>
</html>
4. By Nishit Katole
Made by Nishit Katole. Circle area calculator with css styling. Source

<!DOCTYPE html>
<html>
<head>
<title></title>
<h1>Circle area calculator</h1>
<style>
body {
background-color:hotpink;
text-align:center;
font-weight:800;
font-family:cursive;
}
input{
background-color:blue;
border:2px dashed yellow;
border-radius:30%;
height:30px;
font-weight:900;
color:cyan;
}
button{
background-color:black;
color:lime;
font-weight:800;
border-radius:13px;
height:20px;
}
</style>
</head>
<body>
<hr color="blue">
<br>
<h2>Enter Number:</h2> <br> <input type="text" id="radius">
<br>
<br />
<button onclick="fun()">Get Area</button>
<br><br />
<h3 id="head"></h3>
<script>
function fun()
{
var radius=document.getElementById("radius").value;
var circlearea= 22/7 * (radius * radius);
circlearea= circlearea.toFixed(2);
document.getElementById("head").innerHTML=circlearea;
}
</script>
</body>
</html>
5. By Brain & Bones
Made by Brain & Bones. Source
22 Area of your circle is: 1520.5308443374597
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
h1{
font-size: 50px;
}
body{
height: 450px;
width: 350px;
}
</style>
</head>
<body>
<body bgcolor="red">
<script>
let r = prompt("Enter in the radius of the circle");
var x = (Math.PI) * r * r;
document.write( "<h1>Area of your circle is: " );
document.write(x)
</script>
</body>
</html>
6. By RedBlazerFlame
Made by RedBlazerFlame. Source

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p id="header"><br/>Circle Helper</p>
<div id="main">
<input id="radius" placeholder="radius" oninput="p()">
<button onclick="area()">Show Area</button>
<button onclick="circum()">Show Circumference</button>
<p id="answer"></p>
</div>
<script>
//this was a program made by me 2 years ago, with my current knowledge, i have fixed and improved this old program
var pi=Math.PI;
var r=0;
function p(){
r=radius.value;
}
function area(){
answer.innerHTML=pi*r*r+" square units";
}
function circum(){
answer.innerHTML=2*pi*r+" units";
}
addEventListener('resize',resize);
function resize(){
main.style.width=window.innerWidth;
}
var red=255;
var green=0;
var blue=0;
var kf=0;
var rainbow=setInterval(changecolor,0.1)
function changecolor(){
if(kf<255){
red=red-1;
green=green+1;
}
else if(kf>=255 && kf<510){
green=green-1;
blue=blue+1;
}
else if(kf>=510 && kf<765){
blue=blue-1;
red=red+1;
}
else{
kf=0;
}
average=127.5*Math.sin(2*pi*kf/765)+127.5;
main.style.background="rgb("+red+","+green+","+blue+")";
main.style.border="10px groove rgb("+average+","+average+","+average+")";
++kf;
}
</script>
<style>
#main{
background-color:rgb(255,0,0);
width:window.innerWidth;
height:100px;
border-radius:20px;
border:10px groove gray;
margin-top:50px;
}
#header{
font-family:arial;
font-size:25px;
font-weight:bolder;
text-align:center;
background:#AAAAAA;
box-shadow:inset -100px -10px 10px #FFFFFF,inset 100px 10px 10px #FFFFFF;
margin:0;
width:100vw;
height:100px;
}
</style>
</body>
</html>
7. By TwoPTwo
Made by TwoPTwo. JavaScript Area of circle program using event drive. Source
23 Area of circle is 1662.5714285714284 units.
<html>
<body>
<form name="f1" onsubmit="f()">
Enter a value for radius :<input type="number" name="t1"><br><br>
<input type="submit">
</form>
<script language="javascript">
function f()
{
var d=f1.t1.value;
document.write("Area of circle is " +(22/7)*d*d+" units.");
}
</script>
</body>
</html>
8. By Roel
Made by Roel. Source
24 area:1809.5573684677208
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#knop {
background-color:rgb(240,240,240);
border:3px solid;
width:80px;
height:20px;
margin-top:210px;
margin-left:130px;
border-color:rgb(200,200,200)
rgb(120,120,120)
rgb(120,120,120)
rgb(200,200,200);
}
.tekst {
text-decoration:none;
font-family:"Arial Black";
text-color:red;
}
</style>
</head>
<body>
<div align="center" id="knop"><b class="tekst"><a href="https://code.sololearn.com/WEj00YimiCZi/?ref=app">HELP</a></b></div>
<script>
var r=prompt("Enter your circle's radius (diameter/2)");
var d=r*r;
var opp=d*Math.PI;
var o=r*Math.PI;
alert("your circle's area = "+opp+" m2/cm2/whatever");
alert("your circle's circumference = "+o+" m/cm/whatever");
document.write("area:"+opp);
document.write(" circumference:"+o);
</script>
</body>
</html>
9. By Gangineni Goutham Choudary
Made by Gangineni Goutham Choudary. Simple Circle Area finder. Source
25 1963.4954084936207
var rad=Number(prompt("Enter radius of the Circle."));
var pi=Math.PI;
var rsqr=rad*rad;
document.write(pi*rsqr)
10. By Nico
Made by Nico. Source
26 The area of a circle with radius 26 is 2123.7166338267
var radius = prompt("Enter radius", "");
var answer = (radius*radius)*Math.PI;
alert("The area of a circle with radius "+ radius + " is " + answer);