SultanC
  1. Home
  2. Examples
  3. Control flow

Loops with while

control_flow/loops.sn
def main(): int {
    let current: mutable int = 1;
    let total: mutable int = 0;
    while (current <= 6) {
        total := total + current;
        current := current + 1;
    }
    return total;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/control_flow/loops.sn

Or compile it to an executable:

./build/sultanc examples/en/control_flow/loops.sn -o build/example && ./build/example

Source on GitHub   All examples