write a program in JavaScript to find area of a circle.
Answers
Answered by
3
Solution:
Here comes the JavaScript code for the question. Write the script inside script tag -
window.onload= function calculateArea(){
var a=parseInt(prompt("Enter Length of the Radius: ","Enter."));
var area=Math.PI*a*a;
alert("Area is: "+area);
}
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