JavaScript Hipotenüs Hesaplama (Pisagor teoremi)

Beratx

Kızıltaş madencisi
Katılım
8 Şub 2021
Mesajlar
99
Beğeni
69
Puanları
450
JavaScript:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>
    <h2>JavaScript Hipotenüs Hesaplama</h2>
    <input placeholder="1. Kenarı girin" type="text" id="txtKenar1">
    <input placeholder="2. Kenarı girin" type="text" id="txtKenar2">
    <button id="btn">HESAPLA</button>
    <div id="sonuc"></div>

    <script>
        function Hesapla()
        {
            var k1=Number(document.getElementById("txtKenar1").value);
            var k2=Number(document.getElementById("txtKenar2").value);
            var hipotenus=Math.sqrt((k1*k1)+(k2*k2));
            document.getElementById("sonuc").innerHTML="Hipotenüs : "+hipotenus;
        }
      
        var hesapBtn=document.getElementById("btn");
        hesapBtn.onclick=Hesapla;
      
    </script>
  
</body>
</html>
 
Üst