Conditional structures: Difference between revisions

Content added Content deleted
(Added solution for Action!)
(Added PL/M)
Line 5,369: Line 5,369:
* the '''do''' ... '''end''' statements can be omitted if the when clause is a single statement.
* the '''do''' ... '''end''' statements can be omitted if the when clause is a single statement.
* if no '''other''' (or in full: '''otherwise''') statement is present and none of the '''when''' cases is matched, the program will end in error.
* if no '''other''' (or in full: '''otherwise''') statement is present and none of the '''when''' cases is matched, the program will end in error.

=={{header|PL/M}}==
IF-THEN-ELSE:
<lang pli>/* IF-THEN-ELSE - THE ELSE STATEMENT; PART IS OPTIONAL */
IF COND THEN STATEMENT1; ELSE STATEMENT2;

/* CAN BE CHAINED - THE ELSE STATEMENTX; PART IS STILL OPTIONAL */
IF COND1 THEN STATEMENT1;
ELSE IF CONB2 THEN STATEMENT2;
ELSE IF CONB3 THEN STATEMENT3;
ELSE STATEMENTX;</lang>

DO-CASE:
<lang pli>/* CASE STATEMENT - EXECUTES STATEMENT0, STATEMENT1, ETC. */
/* DEPENDING ON WHETHER EXPR EVALUATES TO 0, 1, ... */
/* EXPR MUST BE IN RANGE OR THE PROGRAM WILL JUMP TO HYPERSPACE */
DO CASE EXPR;
STATEMENT0;
STATEMENT1;
...
END;</lang>


=={{header|Pop11}}==
=={{header|Pop11}}==