Thursday, 4 September 2014

COBOL Decision Making | PERFORM statement | If-Then-Else structure | Do structure

A technique that make the programs easier to read, debug, and modify sometimes referred to as GO-TO-Less programming; each section of a program is written as an independent module and executed using a PERFORM statement.
The basic theory of structured programming is that any program can be written using only three logical structures. They are called the sequence, selection, and iteration structures.
COBOL
COBOL Decision Making.

SEQUENCE : A sequence structure (or Do structure) consists of one or more functions executed in sequence. Each function consists of one or more imperative statements like Move, Accept, or Display statements.



SELECTION : The selection structure (or If-Then-Else structure) provides a choice between two functions based on a condition. In COBOL, this structure is implemented by an If statement. If the condition is true, one function is done; if it’s false (Else), the other function is done. If one of the functions is omitted (null), the structure is still valid. In that case, the Else clause can be omitted.

Iteration : The iteration structure performs a function repeatedly as long as a condition is true (the DO While structure) or until a condition becomes true (the Do Until structure). In COBOL, though, the DO Until structure is usually implemented by the Perform Until structure, which is slightly different than the Do Until structure. The difference is that the condition is tested after the function is performed in the Do Until structure and before the function is performed in the Perform Until structure. 

No comments:

Post a Comment

New In-feed ads