Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sequence, Selection, Iteration The IF Statement

Similar presentations


Presentation on theme: "Sequence, Selection, Iteration The IF Statement"— Presentation transcript:

1 Sequence, Selection, Iteration The IF Statement
COBOL Sequence, Selection, Iteration The IF Statement

2 IF Statement Simplified basic syntax: IF condition statement
What is a condition? An expression formed using relational or logical operators

3 Relational Operators = equal to > greater than < less than
NOT = not equal to NOT > not greater than NOT < not less than >= greater than or equal to <= less than or equal to

4 Logical Operators AND OR
Compound Conditions – conditional expressions formed by usage of one or more logical operators, for example, IF A < 100 AND B > IF A = 0 OR B = IF A > 0 AND B > 0 OR C <

5 Precedence for Evaluation of Logical Expressions
HIGH simple condition (relational expression) complex condition in parentheses NOT AND LOW OR Consider: NOT (NOT A < 10 AND B = 4) {if A=6, B=6}

6 Precedence for Evaluation of Logical Expressions
HIGH simple condition complex condition in parentheses NOT AND LOW OR Consider: NOT (NOT A < 10 AND B = 4) {if A=6, B=6} T F

7 Precedence for Evaluation of Logical Expressions
HIGH simple condition complex condition in parentheses NOT AND LOW OR Consider: NOT (NOT A < 10 AND B = 4) {if A=6, B=6} T F false

8 Precedence for Evaluation of Logical Expressions
HIGH simple condition complex condition in parentheses NOT AND LOW OR Consider: NOT (NOT A < 10 AND B = 4) {if A=6, B=6} T F false

9 Precedence for Evaluation of Logical Expressions
HIGH simple condition complex condition in parentheses NOT AND LOW OR Consider: NOT (NOT A < 10 AND B = 4) {if A=6, B=6} T F false true

10 Logical Expressions (Conditions)
Can appear in clauses other than IF statement. PERFORM …UNTIL EVALUATE other . . .

11 IF with ELSE Simplified basic syntax:
IF condition statement(s) ELSE statement(s) END-IF


Download ppt "Sequence, Selection, Iteration The IF Statement"

Similar presentations


Ads by Google