Note : The variable 'a' has the value 3 and 'b' has the value 8. These values will NOT change - in other words, these values will be same for every example.
|+||addition||a + b||11|
|-||subtraction||5 - a||2|
|*||multiplication||3 * b||24|
|/||division||6 / a||2|
In this example a is 'Hello' and b is 'World'.
|+||concatination||a + b||HelloWorld|
|++||Adds 1 to the value on the left (so if i were equal to 1, i++ would equal 2)||a++||a will be 4|
|--||Subtracts 1 from the value on the left.||a--||a will be |
|+=||Adds the values to the left and right of the operator and then stores the value in the left variable.
||a += b||a will be 11|
|-=||Subtracts the values to the left and right of the operator and then stores the value in the left variable.
||b -= a||b will be 5|
|*=||Multiplies the values to the left and right of the operator and then stores the value in the left variable.
||a *= b;||a will be 24|
|==||equality||if(a == b)||False|
|!=||inequality||if(a != b)||True|
|<||less than||if(a < b)||True|
|>||greater than||if(a > b)||False|
|<=||less than or equal||if(a <= b)||True|
|>=||greater than or equal||if(a >= b)||False|
||if(a>b && b>7)||False|
||if(a>b || b>7)||True|
Now lets put those operators to good use by looking at the Control flow structures - where operators will be used most.
blog comments powered by