PROGRAM demonstrate_conditional_branching;
VAR one,two,three : INTEGER;
BEGIN (* main program *)
one := 1; (* these are to have some numbers *)
two := 2; (* to use for illustrations *)
three := 3;
IF three = (one + two) THEN (* Example 1 *)
WRITELN('three is equal to one plus two');
IF three = 3 THEN (* Example 2 *)
BEGIN
WRITE('three is ');
WRITE('equal to ');
WRITE('one plus two');
WRITELN;
END;
IF two = 2 THEN (* Example 3 *)
WRITELN('two is equal to 2 as expected')
ELSE
WRITELN('two is not equal to 2... rather strange');
IF two = 2 THEN (* Example 4 *)
IF one = 1 THEN
WRITELN('one is equal to one')
ELSE
WRITELN('one is not equal to one')
ELSE
IF three = 3 THEN
WRITELN('three is equal to three')
ELSE
WRITELN('three is not equal to three');
END. (* main program *)