Page 92 - CA_Blue( J )_Class10
P. 92

12              a=sc.nextInt();
                13              b=sc.nextInt();

                14              s=a+b;
                15              System.out.println("The result is : "+s);

                16          }
                17          catch(Exception ex)

                18          {
                19              System.out.println("You are supposed to enter an integer value");

                20          }
                21      }

                22  }

              Output: If taken a double value













              Output: If taken an integer value















                   5.8 COMMENTS IN JAVA
              Comments are non-executable statements used to explain the code such as why the variable has been used, what is
              the purpose of the function, etc. Comments can also be used to hide the code from the compiler without deleting
              it. Commented statements are ignored by the compiler. Comments help the programmers to debug any error easily.
              There are three types of comments in Java which are as follows:
              •  Single Line Comments: These comments are used to write one line comments. A single line comment begins with
                 "//" (double forward slash). For example:
                  void show()
                  {
                      System.out.println("Single Line Comment");
                      //This statement prints Single Line Comment
                  }



                9090  Touchpad Computer Applications-X
   87   88   89   90   91   92   93   94   95   96   97