Page 387 - Web Applications (803) Class 11
P. 387
30. Write JavaScript code to accept a number from the user. Display the next 5 numbers from this number.
Ans. <html>
<body text=”blue”>
<script>
var num = prompt(“Enter a number”);
document.write(“You entered “ + num + “ The next 5 numbers are:”);
for (var i = num; i <= parseInt(num) + 5; i++) {
document.write(“<br>” + i);
}
</script>
</body>
</html>
Output:
Practical Work 385

