COBOL IF Conditional Expressions

COBOL IF Statement COBOL Evaluate

Advertisements


The conditions used in IF statements are basically three types.


  1. Sign
  2. Relation
  3. Complex

Let’s see how it was one by one.


IF Sign condition:


IF SIGN condition is used to verify the sign of a particular data item.

There are three types sign validation.


  1. POSITIVE
  2. NEGITIVE
  3. ZERO

Sign condition type syntax:

IF	Identifier/data-name IS [NOT] {POSITIVE/NEGATIVE/ZERO}			

IF Sign condition - Practical Example:

Code:



Jcl:



Output:



IF Relation condition:


IF Relation condition is used to verify the relation between two identifiers/literals.

The below are the IF relational conditions


  1. GREATER THAN
  2. LESS THAN
  3. EQUAL
  4. NOT

Relation condition type syntax:

IF	{Identifier/Literal} IS [NOT] 	{GREATER THAN/
					>/
					LESS THAN/
					=/
					LESS THAN OR EQUAL TO/
					<=}
					{Identifier/Literal}

IF Relation condition - Practical Example:

Code:



Jcl:



Output:



IF Complex condition:


IF complex condition is used to verify the one or more sign or relational types.

Complex condition is the combination of conditions by using AND/OR operators

The below are the IF complex conditions


  1. AND
  2. OR

Complex condition type syntax:

IF Condition {AND/OR} Condition

IF Complex condition - Practical Example:
Code:



Jcl:



Output:



COBOL IF Statement COBOL Evaluate

Advertisements