

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Calculate difference between circumference and area of a circle - JavaScript
Circumference of a circle is given by −
pi * (r * r)
And area of a circle is given by −
2 * pi * r
Where r is the radius of the circle.
We are required to write a JavaScript function that takes in the radius of circle and calculates the difference between the area and the circumference of the circle
Example
Let’s write the code for this function −
const rad = 6; const circleDifference = radius => { const area = Math.PI * (radius * radius); const circumference = 2 * Math.PI * radius; const diff = Math.abs(area - circumference); return diff; }; console.log(circleDifference(rad)); console.log(circleDifference(5.25)); console.log(circleDifference(1));
Output
The output in the console −
75.39822368615503 53.60342465187584 3.141592653589793
- Related Questions & Answers
- How to calculate the area and perimeter of a circle in JavaScript?
- Java program to find the circumference of a circle
- Program to find Circumference of a Circle in C++
- Program to calculate the area of an Circle inscribed in a Square
- Program to calculate area and volume of a Tetrahedron
- Area of circle inscribed within rhombus?
- Program to calculate area and perimeter of Trapezium
- Area of a circle inscribed in a regular hexagon?
- Area of a Circumscribed Circle of a Square in C++
- Java program to find the area of a circle
- Find the area of a circle in C programming.
- Python Program to find the area of a circle
- Find the Area of a Circle in Java Program
- Program to calculate the area of a Tetrahedron
- Java Program to calculate area of a Tetrahedron
Advertisements