WRITE A JAVASCRIPT PROGRAM TO DISPLAY ON THE ALERT BOXES THE AREA AND DIAMETER OF A CIRCLE WHOSE RADIUS IS 10 cm. FOR CLASS 7 PLS IT'S IMPORTANT
Answers
Answered by
3
Required Answer:-
Question:
- Write a JavaScript program to display on the alert boxes the area and diameter of a circle whose radius is 10 cm.
Solution:
Here is the program.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<>
function myFunction() {
var r = 10.0;
var d = 2 * r;
var a = 3.14 * r * r;
alert("Diameter is " + d + " cm and area is " + a + "cm²");
}
</>
</head>
<body onload="myFunction()"> </body>
</html>
Algorithm:
- Declare and initialise variable with value 10.0
- Calculate the value of diameter and area using formula and display the result using alert box.
Refer to the attachment.
Attachments:
Similar questions