Computer Science, asked by prashansaa7, 2 months ago

write a program in JavaScript to find area of a circle.​

Answers

Answered by anindyaadhikari13
3

Solution:

Here comes the JavaScript co‎de for the question. Write the script inside script tag -

\rule{315}{2}

  window.onload= function calculateArea(){

   var a=parseInt(prompt("Enter Length of the Radius: ","Enter."));

   var area=Math.PI*a*a;

   alert("Area is: "+area);

  }

\rule{315}{2}

When the page is loaded, the function calculateArea() is called which asks the user to enter the radius from the prompt. Then, area is calculated by using formula and it is displayed through alert message.

See the attachments for the output.

•••♪

Attachments:
Similar questions