Log in from a computer to take this course

You'll need to log in from a computer to start Learn C++. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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 &&.

Instructions

1.

Write the following if statement:

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

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?