HTML CSS AND JAVASCRIPT CODE FOR ALL SIDES OF TRIANGLE

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Triangle Area - All Sides</title>
</head>
<body>
    <input type="number" id="a" placeholder="Side A">
    <input type="number" id="b" placeholder="Side B">
    <input type="number" id="c" placeholder="Side C">
    <button onclick="calculateArea()">Calculate Area</button>
    <div id="areaResult"></div>

    <script>
        function calculateArea() {
            const a = parseFloat(document.getElementById('a').value);
            const b = parseFloat(document.getElementById('b').value);
            const c = parseFloat(document.getElementById('c').value);
            const s = (a + b + c) / 2;
            const area = Math.sqrt(s * (s - a) * (s - b) * (s - c));
            document.getElementById('areaResult').textContent = `Area: ${area}`;
        }
    </script>
</body>
</html>
JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *


error: Content is protected !!
Scroll to Top
MacroNepal
Verified by MonsterInsights