005-004-011
Logical Operators Basics
Easy
Problem Description
Logical Operators Basics
In this problem: You will create a program that demonstrates logical operators (&&, ||, !) with boolean variables, performs eligibility checks (age >= 18 AND has license), and displays the results including short-circuit evaluation behavior to standard output.
Learning Objective: Understand basic usage of logical operators and the concept of short-circuit evaluation
Overview
Perform the following operations:
- Check eligibility with
age = 20,hasLicense = trueand display result - Check eligibility with
age = 16,hasLicense = trueand display result - Display
||operator result for "member or student" check - Display
!operator result for boolean negation
Specifications
- Determine eligibility with
eligible = (age >= 18) && hasLicense - Set
isMember = false,isStudent = trueand evaluateisMember || isStudent - Set
isRaining = falseand evaluate!isRaining
Output Format
Age: 20, Has License: true -> Eligible: true
Age: 16, Has License: true -> Eligible: false
isMember || isStudent: true
!isRaining: true
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up