Combined Condition


  • A combined condition is a logical group with two or more conditions.
  • It is used to test multiple conditions to produce a single decision.
  • It uses AND and OR to combine multiple conditions.

Syntax -

AND -


The combined condition is true when all conditions coded in it are true with AND.

For example - Employees who have a salary greater than 50000 and have been with the company for more than 5 years are eligible for bonus.

IF  WS-SALARY > 50000 
AND WS-YEARS-OF-SERVICE > 5
    DISPLAY "ELIGIBLE FOR BONUS"
ELSE
    DISPLAY "NOT ELIGIBLE FOR BONUS"
END-IF

OR -


The combined condition is true when either one or all condition(s) are true with OR.

For example - Employees with a salary greater than 50000 or who have been with the company for more than 5 years are eligible for a bonus.

IF WS-SALARY > 50000 
OR WS-YEARS-OF-SERVICE > 5
    DISPLAY "ELIGIBLE FOR BONUS"
ELSE
    DISPLAY "NOT ELIGIBLE FOR BONUS"
END-IF

Combining AND and OR Together -


We can also use both 'AND' and 'OR' in a single combined condition. It is important to use parentheses () to describe the order in which the conditions are evaluated.

For example - Employees who have a salary greater than 50000 and have been with the company for more than 5 years or who are in a managerial position are eligible for the bonus.

IF (WS-SALARY > 50000 AND WS-YEARS-OF-SERVICE > 5) 
OR WS-POSITION = 'MANAGER'
    DISPLAY "ELIGIBLE FOR BONUS"
ELSE
    DISPLAY "NOT ELIGIBLE FOR BONUS"
END-IF

Table for Result validation -


Condition1 (C1)Condition2 (C2)C1 AND C2C1 OR C2NOT (C1 AND C2)NOT (C1 OR C2)
True TrueTrue TrueFalse False
False TrueFalse TrueTrue False
True FalseFalse TrueTrue False
False FalseFalse FalseTrue True