Skip to Content
Logical Operators
Logical Operator: &&

The and logical operator is denoted by &&.

It returns true if the condition on the left and the condition on the right are both true. Otherwise, it returns false.

Here’s the truth table:

a b a && b
false false false
false true false
true false false
true true true

For instance:

  • ( 1 < 2 && 2 < 3 ) returns true
  • ( 1 < 2 && 2 > 3 ) returns false

Note: The keyword and can also be used in the place of &&.



Write the following if statement:

  • If hunger is true and anger is true, then print out the word "Hangry".
Folder Icon

Take this course for free

Already have an account?