February 2014
Beginner
1248 pages
62h 25m
English
Suppose we wish to ensure at some point in a program that two conditions are both true before we choose a certain path of execution. In this case, we can use the && (conditional AND) operator, as follows:
if (gender == FEMALE && age >= 65) ++seniorFemales;
This if statement contains two simple conditions. The condition gender == FEMALE compares variable gender to the constant FEMALE to determine whether a person is female. The condition age >= 65 might be evaluated to determine whether a person is a senior citizen. The if statement considers the combined condition
gender == FEMALE && age >= 65
which is true if and only if both simple conditions are ...
Read now
Unlock full access