Page 160 - Computer science 868 Class 12
P. 160

2.  Subtraction (-) Operator: It is used for finding the difference between two values either of integer literal or real
                 literal. The result may be positive or negative depending on the values.
                For example:  if int a = 5, b = 2;
                             a-b = 5-2 = 3
                             b-a = 2-5 = -3
              3.  Multiplication (*) Operator: It is used for multiplying two values either of integer literal or real literal. The result
                 may be positive or negative depending on the values.
                For example:  if int a = 10, b = 15;
                             a*b = 10*15 = 150
              4.  Division (/) Operator: It is used for finding the quotient of two values either of integer literal or real literal. The
                 result may be positive or negative depending on the values.
                For example: if int = 40, b = 10;
                             a/b = 40/10 = 4
                             b/a = 10/40 = 0 (because int/int will be int)

              5.  Remainder or Modulus (%) Operator: It is used for finding the remainder of two values either of integer literal or
                 real literal. The result may be positive or negative depending on the values.

                For example:  if int a = 40, b = 10;
                             a%b = 40%10 = 0
                             b%a = 10%40 = 10
              Let us summarise the arithmetic operators in the table given below.

                             S. No.            Operator                Example               Output
                                                                                          (int a=20, b=4)
                               1      Addition (+)                      a + b                  24
                               2      Subtraction (-)                   a - b                  16
                               3      Multiplication (*)                a * b                  80
                               4      Division (/)                      a / b                  5
                               5      Remainder or Modulus (%)          a % b                  0


              6.5.2 Relational Operators
              The relational operators compare two variables or expressions and the resultant output is the relation between them.
              The output is given in the boolean form, i.e., true or false. They operate on numbers and characters. But they are not
              applicable to String or boolean type.

              There are six relational operators in Java language which are demonstrated below.

                             S.No.       Operator           Meaning            Example          Result
                                                                             int a=10, b=2
                               1.           >         Greater than               a > b     true
                               2.           >=        Greater than or Equal to  a >= b     true
                               3.           <         Less than                  a < b     false
                               4.           <=        Less than or Equal to     a <= b     false
                               5.           ==        Equal to                  a == b     false
                               6.           !=        Not Equal to              a != b     true




                158158  Touchpad Computer Science-XII
   155   156   157   158   159   160   161   162   163   164   165