# Combined Condition

A combined condition is logically grouping two or more conditions. A combined condition is used to test multiple conditions at once.

Syntax -

A combined condition uses AND and/or OR to combine multiple conditions together.

## AND -

When we combine conditions using AND, all conditions must be true for the combined condition to be true.

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 -

When we combine conditions using OR, either one or both condition(s) needs to be true for the combined condition to be true.

For example - Employees who have a salary greater than 50000 or have been with the company for more than 5 years are eligible for 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, but it’s important to use parentheses () to clarify 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 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 -

Condition C1Condition C2C1 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