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
   382   383   384   385   386   387   388   389   390   391   392