CBSE 10. WEB SCRIPTING - JAVA SCRIPT (5 MARKS)

 

18. Rounding Off a Number

JavaScript

<!DOCTYPE html>

<html>

<head>

<title>Rounding Number</title>

</head>

<body>

 

<script>

  var num = 3.14159;

  var roundedNum = Math.round(num);

  document.write("Rounded number: " + roundedNum);

</script>

 

</body>

</html>

This rounds the number 3.14159 to the nearest integer (3).

No comments:

Post a Comment