vault backup: 2023-10-05 09:27:25

This commit is contained in:
Louis Gallet 2023-10-05 09:27:25 +02:00
parent 37c662ef10
commit ba47331c40
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

View File

@ -23,3 +23,44 @@ unit SumWhile(unit n)
return loop;
}
```
### Iteration statements - do (..) while
```cs
do
{
// Repeat stuff
} while (condition)
```
Same thing that the other one but return in a different way
**Example**
```cs
uint SumDoWhile(uint n)
{
uint loop = 0;
do
{
loop += 1;
n = n - 1;
} while (n > 1):
return loop;
}
```
## For loop
```cs
for ([initialize]; [condition]; [iterator])
{
// Repeat stuff
}
```
**Example:**
```cs
uint SumFor(uint n)
{
uint res = 0;
for (uint i = 1; i < n; ++i)
{
res += 1;
}
return res;
}
```