Question: Consider the code snippet which is to implement what is said in the comment line ; assumed to be in a program in which all
Consider the code snippet which is to implement what is said in the comment line ; assumed to be in a program in which all variables are correctly defined:
// deal with ages 10-15, inclusive if (!(myAge > 15 || myAge < 10)) age_category_two = true;
According to
the syntax rules of C++,
the use of logical and relational expressions with clarity and simplicity as advocated in our lessons,
What would be a better way to write the if construct?
| if ( !( (myAge > 15) || (myAge < 10) ) |
| if ( !( (myAge >= 15) || (myAge <= 10) ) |
| if ( !( !(myAge >= 10) || !(myAge <= 15) ) ) |
| if ( (myAge !> 15) && (myAge !< 10) ) |
| if ( myAge >= 10 && myAge <= 15 ) |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
