# 9+ JavaScript Programs to Calculate Area of a Circle

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.

## JavaScript Programs to Calculate Area of Circle

### 1. By LynTon

Made by LynTon. Simple Circle Area Calculator. Source

``````<!DOCTYPE HTML>
<html>
<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;
}

text-decoration: underline;
}
</style>
<body>

<input type="button" onclick="calculate()" value="Calculate area">
<p>Area: <span id="area">???</span></p>

<script>
function calculate() {
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){

}

document.write("The area of the circle is "+ circleArea(r));

console.log("Area =" +circleArea(r));``````

### 3. By Sharvil Khot

```21
Area of the circle is 1384.74```
``````<!DOCTYPE html>
<html>
<title></title>
<body>
<script type="text/Javascript">
var r,area
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>
<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;
height:30px;
font-weight:900;
color:cyan;
}

button{
background-color:black;
color:lime;
font-weight:800;
height:20px;
}
</style>
<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 />
<script>
function fun()
{
circlearea= circlearea.toFixed(2);

}
</script>
</body>
</html>``````

### 5. By Brain & Bones

Made by Brain & Bones. Source

```22
Area of your circle is: 1520.5308443374597```
``````<!DOCTYPE html>
<html>
<title>Page Title</title>
<style>
h1{
font-size: 50px;
}
body{
height: 450px;
width: 350px;
}

</style>
<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

``````<!DOCTYPE html>
<html>
<title>Page Title</title>
<body>
<div id="main">
<button onclick="area()">Show Area</button>
<button onclick="circum()">Show Circumference</button>
</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(){
}
function area(){
}
function circum(){
}
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:10px groove gray;
margin-top:50px;
}
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

```24
area:1809.5573684677208```
``````<!DOCTYPE html>
<html>
<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>
<body>
<div align="center" id="knop"><b class="tekst"><a href="https://code.sololearn.com/WEj00YimiCZi/?ref=app">HELP</a></b></div>
<script>
var d=r*r;
var opp=d*Math.PI;
var o=r*Math.PI;
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;
```26
``````var radius = prompt("Enter radius", "");