Programming with JavaScript

⌘K
  1. Home
  2. Docs
  3. Programming with JavaScri...
  4. Example Programs
  5. Area of Circle

Area of Circle

Example 6:

Create a variable called “pi” and assign the value of 3.14159 to it. Then, create another variable called “radius” and assign a value to it. Calculate the area of a circle using the formula: area = pi * radius^2 and store it in a variable called “circle_area.” Print the result.

const PI = 3.14159;
let radius = 2;
let circle_area = PI * radius * radius;
console.log("Area of circle : ", circle_area);

Output:

Loading

Views: 112

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments