feat: add while loops, break and continue statements

This commit is contained in:
2026-04-21 23:53:41 +02:00
parent 68ec14e541
commit 92eefb5cf1
10 changed files with 397 additions and 9 deletions
+15
View File
@@ -0,0 +1,15 @@
fn main() -> i32 {
let n = 10;
let a = 0;
let b = 1;
let i = 0;
while i < n {
let temp = a + b;
a = b;
b = temp;
i = i + 1;
}
return a;
}
+20
View File
@@ -0,0 +1,20 @@
fn main() -> i32 {
let i = 0;
let sum = 0;
while i < 10 {
i = i + 1;
if i % 2 == 0 {
continue;
}
if i > 7 {
break;
}
sum = sum + i;
}
return sum;
}