This commit is contained in:
retoor 2025-11-23 00:19:52 +01:00
parent 5e1901105a
commit 63f9eb48a4

View File

@ -9,6 +9,11 @@ Complete guide to the RC (Retoor's C) programming language - a C-like interprete
3. [Variables and Declarations](#variables-and-declarations) 3. [Variables and Declarations](#variables-and-declarations)
4. [Arrays](#arrays) 4. [Arrays](#arrays)
5. [Operators](#operators) 5. [Operators](#operators)
- [Arithmetic Operators](#arithmetic-operators)
- [Comparison Operators](#comparison-operators)
- [Logical Operators](#logical-operators)
- [Unary Operators](#unary-operators)
- [Increment and Decrement Operators](#increment-and-decrement-operators)
6. [Control Flow](#control-flow) 6. [Control Flow](#control-flow)
7. [Functions](#functions) 7. [Functions](#functions)
8. [Pointers](#pointers) 8. [Pointers](#pointers)
@ -182,6 +187,54 @@ int main() {
} }
``` ```
### Increment and Decrement Operators
RC supports both pre-increment/decrement (`++x`, `--x`) and post-increment/decrement (`x++`, `x--`) operators.
#### Post-increment (`x++`)
The value of the expression is the value of `x` *before* the increment.
```c
int main() {
int x = 5;
int y = x++; // y is 5, x becomes 6
printf("x = %d, y = %d\n", x, y);
return 0;
}
```
#### Pre-increment (`++x`)
The value of the expression is the value of `x` *after* the increment.
```c
int main() {
int x = 5;
int y = ++x; // y is 6, x becomes 6
printf("x = %d, y = %d\n", x, y);
return 0;
}
```
#### Post-decrement (`x--`)
The value of the expression is the value of `x` *before* the decrement.
```c
int main() {
int x = 5;
int y = x--; // y is 5, x becomes 4
printf("x = %d, y = %d\n", x, y);
return 0;
}
```
#### Pre-decrement (`--x`)
The value of the expression is the value of `x` *after* the decrement.
```c
int main() {
int x = 5;
int y = --x; // y is 4, x becomes 4
printf("x = %d, y = %d\n", x, y);
return 0;
}
```
## Control Flow ## Control Flow
### If-Else Statements ### If-Else Statements