JavaScript Program to Calculate Area of a Circle Using

Write a JavaScript program to calculate area of a circle using with statement.



Source Code
<html>

<head>
  <title> with statement example </title>
</head>
<body>
<script language="javascript" type="text/javascript">  
  var area, circumference;
  var r = 10;
  with (Math)
  {
    area = PI * r * r;
    circumference = 2 * PI * r;
  }
  with (document)
  {
    write("Area of the Circle: " + area + "<br>");
    write("Circumference of the Circle: " + circumference);
  }
</script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store