8. ternary (3 operands) exp1 ? exp2 : exp3 For example: a = b + c; denote an expression in which there are 3 operands a, b, c and two operator + and = .
36. Operator Meaning Example Answer + Addition ans = 7 + 3; 10 - Subtraction ans = 7 - 3; 4 * Multiplication ans = 7 * 3; 21 / Division ans = 7 / 3; 2 % Modulus Operator ans = 7 % 3; 1 Cont... Arithmetic Operators
37.
38.
39.
40. Operator Meaning < less than <= less than or equal to > greater than >= greater than or equal to == equal to != not equal to
41.
42. exp1 relational operator exp2 Where exp1 and exp2 are expressions, which may be simple constants, variables or combination of them. Given below are some examples of relational expressions .
54. Statement with simple assignment operator Statement with shorthand operator a = a + 1 a += 1 a = a – 1 a -= 1 a = a * (n+1) a *= (n+1) a = a / (n+1) a /= (n+1) a = a % b a %= b
55.
56.
57. In prefix notation the variable is incremented or decremented first, then the new value is returned.
58. In postfix notation the variable's original value is returned, and the addition or subtraction happens later.
61. You can think of the conditional operator as if it were a function that works like this:
62.
63.
64. Symbol and their Meaning: ~ Complement & And | Or ^ Exclusive-Or << Left shift >> Right shift
65.
66. The exclusive-OR (XOR), it performs same as logical OR operator: The result is 1 only when either X is equal to 1 or Y is equal to 1, but not when both X and Y are equal to 1.