Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript program to find perimeter of a triangle

Improve Article
Save Article
  • Last Updated : 04 Nov, 2022
Improve Article
Save Article

Given the side (a, b, c) of a triangle and we have to find the perimeter of a triangle.

Perimeter: Perimeter of a triangle is the sum of the length of the side of a triangle.

Perimeter of a triangle

Where a, b, and c are lengths of sides of a triangle. The perimeter of a triangle can be simply evaluated using the following formula:

Perimeter = (a + b + c)


Input : a = 2.0, b = 3.0, c = 5.0
Output : 10.0

Input : a = 5.0, b = 6.0, c = 7.0 
Output : 18.0

Example: Below is the implementation of above approach:


    // JavaScript program to find the perimeter
    // of a triangle
    function findPerimeter(a, b, c) {
        // Formula for Perimeter of a triangle
        return (a + b + c);
    // Driver Code
    let a = 2.0, b = 3.0, c = 5.0;
    console.log(findPerimeter(a, b, c));



Time Complexity: O(1).
Auxiliary Space: O(1).

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!