Page 431 - Webapplication11_C11_Flipbook
P. 431
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>
On running the above program, we get the following output:
Practical Work 429

