jab_tak: repeat while something is true
jab_tak means "as long as". It checks the condition, runs the block, and checks again. Something inside the block must eventually make the condition false — here i = i + 1 does that. If you forget it, the loop never ends; AltFLang protects you by stopping after a fixed number of steps and reporting a possible infinite loop.
chalo: counting loops
chalo ("let's go") is the counting loop. Inside its brackets go three parts separated by semicolons: a starting statement, a condition, and an update that runs after each round. The counter made with rakho belongs to the loop.
The classic use is a multiplication table — a pahada.
Expected output
Press Run to try it
7 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 35
bhang: break out early
bhang ("break") leaves the nearest loop immediately. Use it when you have found what you were looking for and there is no point continuing.
aage: skip to the next round
aage ("ahead") skips the rest of the current round and moves on. In a chalo loop the update still runs, so the counter keeps moving.
Combine everything you know and you get FizzBuzz — the most famous beginner exercise.
Practice exercise
FizzBuzz in Hinglish: print the numbers 1 to 15, but print Fizz for multiples of 3, Buzz for multiples of 5 and FizzBuzz for multiples of both.
Expected output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Show solution
chalo (rakho i = 1; i <= 15; i = i + 1) {
agar (i % 3 == 0 && i % 5 == 0) {
bol("FizzBuzz");
} warna agar (i % 3 == 0) {
bol("Fizz");
} warna agar (i % 5 == 0) {
bol("Buzz");
} warna {
bol(i);
}
}