How would you write a program that tells if someone is a teenager? We would need two conditions to be true:
How can we write an if statement to check both conditions? A person is a teenager if age > 12 AND age < 20.
This is how we can check if age > 12 AND age < 20 using the && operator:
if (age > 12 && age < 20) { ...The && operator evaluates to true only when both conditions are true. Run the code sample in this exercise to see the && operator in action.
Output (Console)