Wikia

Borland Pascal Wiki

IF...THEN...ELSE

Talk0
35pages on
this wiki
 This page explains a basic Pascal instruction. If you want to see how to make your own instructions, see Procedures and Functions.
This article is part of the Getting Started series

The conditional instruction is critical in programming and is present in almost all the programming languages. They are usually in the form of
if <condition>
command(s)...
else
command(s)...
The conditional instruction is for acting intelligently, taking one or more actions if a condition is met and other action(s) if another condition is met. For example:

IF b=0 THEN
 write ('You can not do divisions by 0!')
ELSE
 BEGIN
 write (a div b);
 readln;
 END;
end.

So, the syntax is:

if <condition> then <command> else <command>

If there are more commands to execute, they will be grouped in BEGIN ... END. If after IF's command (or the END if there are more commands) there is the ELSE statament, then there must be no semicolon after the previous word.

Around Wikia's network

Random Wiki