Skip to content

Commit

Permalink
Update arithmetic-Operators.md
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanipaliwal authored Aug 10, 2024
1 parent eb7ae3d commit d234c39
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/day-05/arithmetic-Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,22 @@ int result = 10 % 3; // result will be 1

```
These operators can be used with variables, constants, or expressions. They follow the usual rules of precedence and associativity. Additionally, parentheses can be used to enforce a specific order of evaluation.

## Precedence and Associativity of Arithmetic Operators

### Precedence

Precedence determines the order in which different operators are applied in an expression. In C++, the arithmetic operators are grouped into two precedence levels:

- High Precedence:
- Multiplication(*)
- Division(/)
- Modulus(%)
- Low Precedence:
- Additio(+)
- Subtraction(-)

### Associativity

The associativity of arithmetic operators in C++ is left-to-right,i.e, when two operators of the same precedence appear in an expression, they are evaluated from left to right.

0 comments on commit d234c39

Please sign in to comment.