The symbols (or tokens) that trigger computations in the program are called arithmetic operators. They are
Operators | a | b | Evaluation | Result |
---|---|---|---|---|
+addition | 6 | 3 | 6+3 | 9 |
-substraction | 6 | 3 | 6-3 | 3 |
*multiplication | 6 | 3 | 6*3 | 18 |
/Division | 6 | 3 | 6/3 | 2 |
% remainder | 6 | 3 | 6%3 | 0 |
These operators compare two quantities, that is, they determine the relation between two data. The result of the operation will be either TRUE (1) or FALSE (0).
Operators | a | b | Evaluation | Result |
---|---|---|---|---|
> greather than | 6 | 3 | 6>3 | TRUE |
< less than | 6 | 3 | 6<3 | FALSE |
>= Greather than or equal to | 6 | 3 | 6>=3 | TRUE |
<= Less than or equal to | 6 | 3 | 6<=3 | FALSE |
== equal to | 6 | 3 | 6==3 | FALSE |
!= Not equal to | 6 | 3 | 6!=3 | TRUE |
Logical operators are used to combine relational expressions. The operands as well as the result of these operators are Boolean values (TRUE and / or FALSE). The logical AND (&&), Logical OR (||) and logical NOT (!) are the operators. Consider two relational operations with following output then,
Logical AND(&&) | Logical OR(||) | Logical NOT(!) |
---|---|---|
T&&T=T | T||T=T | !T=F |
T&&F=F | T||F=T | !F=T |
F&&T=F | F||T=T | |
F&&F=F | F||F=F |
A bitwise operator is used to perform bitwise operations on bit patterns or binary numerals to perform bit manipulation.
Symbol | Operator |
---|---|
& | BitWise AND |
| | Bitwise Inclusive OR |
^ | Bitwise Exclusive OR |
<< | Left shift |
>> | Right shift |
~ | Bitwise NOT(1's complement,unary) |
This operator returns a value depending on a condition. It is a ternary operator, which requires three operands to operate upon.
result=Condition1 ? Condition 2 : Condition 3;
Example:
result=((a>b)?a:b);
If the value of a is greater than b the value of a will be stored in result otherwise the value of b will stored in b.
It is a unary operator that returns the number of bytes occupied by the variable or data type specified within parentheses
This operator is used to separate group of expressions and evaluate from left to right in sequence.This operator has only limited use cases.
int a=1,b=2,i=0
int a=5, b=3;
++a;-- b;