Computer Science, asked by lovelyrose0090, 2 months ago

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 anindyaadhikari13
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" />

<script>

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²");

}

</script>

</head>

<body onload="myFunction()"> </body>

</html>

Algorithm:

  1. Declare and initialise variable with value 10.0
  2. Calculate the value of diameter and area using formula and display the result using alert box.

Refer to the attachment.

Attachments:
Similar questions