JavaScript Practice Questions And Answer

Problem: Write a program to find out area of circle.
Solution:
            <html>
              <head>
               <title>Circle</title> 
                 <script>
                  function findArea()
                   {
                     var radBox = document.getElementById("input1")
                     var r = parseFloat(radBox.value)
                     var area = 3/14 * r * r
                     var divResult = document.getElementById("result")
                     divResult.innerHTML = "AREA = "+area
                    }
                  </script>
                 </head>
                  <body>     
                   <input type="text" placeholder="Enter radius" id="input1"/>
                   </br>
                   <input type="button" value="Area" id="button1" onclick="findArea()"/>
                   <input type="button" value="Perimeter" id="button2"/>
                   <br>
                   <!--  Area = 3.14 * r * r-->
                   <!-- Perimeter = 2 * 3.14 * r-->
                   <div id="result">
                         area = 0
                   </div>
                   </body>
            </html>
          

Contact Us

Our Address

Plot No. 64, PU-4, Scheme 54, Behind C21 Mall near Hotel Holiday , AB Road, Indore Pin-code:452001

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!