Page 91 - CA_Blue( J )_Class9
P. 91

Program 5      Example of addition (+) operator.

                   1  class addition_operator

                   2  {
                   3      public static void main(int a, int b)

                   4      {
                   5          int c=a+b;

                   6          System.out.println("Result of Addition " + c);
                   7      }

                   8  }
                              Input:                                    You will get the following output:



















                 Subtraction (-) Operator
                 The subtraction (-) operator is used for finding the difference between two values or operands either of integer
                 literals or real literals. The result may be positive or negative depending on the values.   For example:

                        If m = -50, n = 6            then   m - n = -50 - 6 = -56
                        If m = -6.5, n = 1           then   m - n = -6.5 - 1 = -7.5


                  Program 6      Example of subtraction (-) operator.


                   1  class subtraction_operator
                   2  {

                   3      public static void main(int a, int b)
                   4      {

                   5          int c=a-b;
                   6          System.out.println("Result of Subtraction " + c);

                   7      }
                   8  }








                                                                                               Operators in Java   89
   86   87   88   89   90   91   92   93   94   95   96