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

Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!