Chaga Programming Language: Chapter 5: Iteration Statements

Iteration statements

  • The Chaga programming language supports three forms of loop iteration:
    • for
    • while-do
    • do-until
  • The do-until statement differs from for and while-do by iterating at least once.

For statement

  • for (identifier = integer or real constant to integer or real constant) do {statement block}
  • for (identifier = integer or real constant to integer or real constant step integer or real constant) do {statement block}

While-do statement

  • while (expression) do {statement block}

Do-until statement

  • do {statement block} until (expression)

Example 1: for statement

for (i = 0 to 10 step 2) do
{
  printf ("%d ", i)
}
putchar ("\n");

Output from example 1

0 2 4 6 8 10


Copyright © 2025 Robert James Bruce.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at https://www.gnu.org/licenses/fdl-1.3.html