This preview shows pages 1–2. Sign up to view the full content.

CIS 15AG Answers Chapter 5: Selection – Making Decisions 1. Simplify: a. !(a == sqrt( b * b + c * c)) a != sqrt( b * b + c * c) b. !(length >= width + 20) length < width + 20 c. !(cDay < bDay) cDay >= bDay d. !(cMonth != bMonth) cMonth == bMonth 2. Write a C logical expression that evaluates to true if the integer variable score is within the range [80, 90). What's wrong with the following expression? How would you correct it? 8 0 <= score < 90 ( 80 <= score score < 90 ) 80 <= score score < 90 () not needed since the relational operators: < <= > >= == != have a higher precedence than and || 3. Write a logical expression that checks if today is your birthday. int cMonth = 2; // current month int bMonth = 2; // birth month int cDay = 29; int bDay = 29; cMonth == bMonth cDay == bDay 4. Write a C logical expression that evaluates to true if the integer variable score is outside the range [80, 90). score

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}