For loops

Above, i = 0 executes only once, when the for loop first executes. Then condition i < 5 is checked, and if true the sub-statements execute. After, the update i = i + 1 executes, and i < 5 is checked again; the update and check repeat until the condition is false.

Comments

Comments help a human understand code. Each comment starts with //, and must be on its own line. A comment usually describes the code below the comment.

integer i
// Count down from 10 to 0
for i = 10; i >= 0; i = i - 1
Put i to output
// Add a space between numbers
Put " " to output

Arrays

An array variable holds many values rather than just one value. The number of values (size) can be set in the declaration. The size can be read as myArray.size, useful in loops iterating through the array.

integer array(5) userNums
integer i
for i = 0; i < userNums.size; i = i + 1
userNums[i] = i * 2
for i = 0; i < userNums.size; i = i + 1
Put userNums[i] to output

To enable reproducible programs, a programmer can set a seed, as in SeedRandomNumbers(7), prior to any calls to RandomNumber(). Then, for any run of the program, the sequence of “random” numbers is always the same for that seed. Ex: If the above program began with SeedRandomNumbers(0), the program will always output 4, 0, 1. If no seed is provided, Coral by default uses the current time as the seed, yielding the expected “randomness” for each run of the program.