Update.
This commit is contained in:
parent
5e1901105a
commit
63f9eb48a4
53
TUTORIAL.md
53
TUTORIAL.md
@ -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)
|
||||
4. [Arrays](#arrays)
|
||||
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)
|
||||
7. [Functions](#functions)
|
||||
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
|
||||
|
||||
### If-Else Statements
|
||||
|
||||
Loading…
Reference in New Issue
Block a user