Programming with JavaScript

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

Area of Triangle

Example 35

Write the JavaScript to find area of a triangle whose sides are a, b and c

const prompt = require("prompt-sync")();

let a = parseInt(prompt("Enter side 1 : "));
let b = parseInt(prompt("Enter side 2 : "));
let c = parseInt(prompt("Enter side 3 : "));

let s = (a + b + c) / 2;
let area = Math.sqrt(s * (s - a) * (s - b) * (s - c));

console.log(`Area : ${area}`);

Output

Loading

Views: 95

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments