Friday, 12 December 2008

CONDITION


A condition is an entity that at one point of time can have only one of the two values – true or false.

In COBOL a condition can be any one of the following:

i) Relational condition

ii) Sign condition

iii) Class condition

iv) Condition-name condition

v) Negated simple condition

vi) Compound condition



Relational condition indicates a comparison between two operands and has the form
Operand-1 relational-operator operand-2
Where the relational-operator can be any one of the following:








Example program:
IDENTIFICATION DIVISION.
PROGRAM-ID. Relational.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC 9(2).
77 B PIC 9(2).
77 C PIC 9(2).
PROCEDURE DIVISION.
READ-PARA.
DISPLAY “ENTER A VALUE”.
ACCEPT A.
DISPLAY “ENTER B VALUE”.
ACCEPT B.
CAL-PARA.
IF A > B
COMPUTE C = A – B.
RESULT-PARA.
DISPLAY C.
STOP RUN.

No comments:

Post a Comment