Programmer's Guide to the Zeno Interpreter
Chapter 4. Looping and jumping
The Zeno programming language provides several statements that control the sequence of program execution. Each of these control statements must be used entirely within the program module or a subprogram module.
Selection using if and case
These statements are used for conditional branching within a subprogram.
An if control statement has the form:
if boolean expression then
declarations and statements
{elsif boolean expression then
declarations and statements}
[else
declarations and statements]
end if
The boolean expression for each branch is evaluated until one of them is true. The statements in the branch are executed until a closing elsif, else, or end if is reached. If no boolean expression is true then the statements following else, if present, are executed. The program resumes at the first statement after end if. An example:
program
var mark : int
get mark
if mark > 100 then
put "Invalid"
elsif mark >= 93 then
put 'A'
elsif mark >= 85 then
put 'B'
elsif mark >= 78 then
put 'C'
elsif mark >= 70 then
put 'D'
else
put 'F'
end if
end program
|