Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 84 - 2625 PortGPt V2.1
P. 84

    Test Expression

                                                                                        False
                                                                True

                                                           Body of if             Body of else

                                                     Statement just below if

                       Program 3: To compare two numbers and print the result.

                      <!DOCTYPE HTML>

                      <HTML>
                      <HEAD>
                          <TITLE> if-else statement </TITLE>
                      </HEAD>

                      <BODY>
                      <SCRIPT>
                          var a = parseInt(prompt("Enter the first number"));
                          var b = parseInt(prompt("Enter the second number"));

                          if(a > b)
                          {
                            document.write("First number is greater then second number");

                          }
                          else
                          {
                            document.write("Second number is greater then first number");

                          }
                      </SCRIPT>
                      </BODY>
                      </HTML>

                      82    Premium Edition-VIII

| 79 80 81 82 83 84 85 86 87 88 89 |