Skip to main content
Skip to content

Loops keyword

jab_tak — while loop

jab_tak repeats its block for as long as the condition stays truthy, checking before every round.

Meaning: "as long as / until"

How jab_tak works

The keyword is one word joined by an underscore: jab_tak. The condition is checked first, so if it starts false the body never runs.

Something inside the loop must eventually make the condition false. If nothing does, AltFLang stops the program after a fixed step budget and reports a possible infinite loop instead of freezing your browser.

Use jab_tak when you do not know in advance how many rounds you need — reading input until it runs out, halving a number until it reaches 1, or retrying until a guess is right. For a fixed count, chalo is tidier.

Syntax

syntax
jab_tak (condition) {
  // body
}

Runnable example

Expected output

Press Run to try it

100 ko 6 baar half kiya

Same idea in JavaScript and Python

JavaScript
let n = 100;
let steps = 0;
while (n > 1) {
  n = Math.floor(n / 2);
  steps = steps + 1;
}
Python
n = 100
steps = 0
while n > 1:
    n = n // 2
    steps = steps + 1

Common mistakes

Forgetting to update the counter

Without i = i + 1 the condition never changes, so the loop runs until the step limit stops it.

Galat
rakho i = 0;
jab_tak (i < 3) {
  bol(i);
}
Sahi
rakho i = 0;
jab_tak (i < 3) {
  bol(i);
  i = i + 1;
}

Writing jab tak as two words

jab tak with a space is two unknown names. The keyword is jab_tak.

Galat
jab tak (x < 5) { }
Sahi
rakho x = 0;
jab_tak (x < 5) { x = x + 1; }
bol(x);

jab_tak: frequently asked questions

What is the while loop in Hindi programming?

In AltFLang it is jab_tak, meaning "as long as". jab_tak (condition) { ... } repeats the block while the condition is truthy.

Is there a do-while loop?

No. To run the body at least once, set the condition variable so it starts true, or write the body once before the loop.