An expression is a combination of variables, constants, and operators that produces a result.
Example:
int result = (a + b) * c – d;
Operator Precedence
|
Priority |
Operators |
Associativity |
|
1 (High) |
() |
Left to Right |
|
2 |
++, –, – (Unary) |
Right to Left |
|
3 |
*, /, % |
Left to Right |
|
4 |
+, – |
Left to Right |
|
5 |
Relational |
Left to Right |
|
6 |
Logical |
Left to Right |
|
7 |
=, +=, -= etc. |
Right to Left |
Type Conversion:
Implicit Conversion: Done automatically by the compiler
int x = 10;
float y = x + 2.5; // x is automatically converted to float
Explicit Conversion (Type Casting):
float a = 10.5;
int b = (int)a; // Converts float to int manually