Professional Documents
Culture Documents
The Logical Or: Semesteraverage 90
The Logical Or: Semesteraverage 90
The Logical Or: Semesteraverage 90
In the last guide, we talked about the LOGICAL NOT and the LOGICAL AND operator. Today we
are going to talk about the LOGICAL OR operator. The logical or is denoted by ||.
Suppose you are a student at a university. You sit for your math final exam. Now, if you get 90% in
your final exam of the subject or if you get 90% in the overall subject, you get an A. Let’s see this in
code:
int semesterAverage = 85;
int finalExamMark = 92;
The output of the above code will be Student got an A. This is because one of the conditions inside
the if-statement is true that is finalExamMark >= 90 is true. The definition goes like this: if either or
both condition is true, execute the if-statement. Otherwise, if both conditions are false (conditions
are marked in red and green) execute the else statement.
OR
Condition 1 inside if Condition 2 inside if Which statement will be
executed