Operators
An expression is a sequence of operators and their operands, that specifies a computation.
Binary Operators
Here is an example of each binary operators:
Here a = 3.
Here a = 1.
Here a = 4.
Here a = 5.
Here a = 5.
Here a = 10.
Here a = 10.
Here a = 10.
Here a = 10.
Here a = 10.
Here a = 10.
Operators Priority
The C-- defines different priority for each operators, it is defined by a number that go from 1 (very low priority) to 9 (biggest priority)
Here is a table with the default priority for operators:
Considering the following example, we can see that we can chain operators when we want to compute values:
Here, the integer i will be equal to 3 and b equal to 9 considering the calculation priority.
Infix Operators
In C-- it's possible to change the operator priority and it's possible to assign an operating priority to functions
In this case tona is considered as an infix operator and the * operator has a lower priority than tona. So here i = 3 tona 7 * 3. So i = 3 * 3 = 9.
Another example:
In this case tona is considered as an infix operator but it acts like the + operator. In C-- `+`= means +=. So here a = 6.
Unary Operators
Here is an example of each unary operators:
Here the character stored in the variable c is written.
Here (?h) dereference its pointer.
Here the string strg is displayed because the value a is incremented to 2 with the ++ operator.
Here the string strg is displayed because the value a is incremented to 2 with the -- operator.
Post-fix Operators
Here the 5th character of str is c.