Our program that distinguished between high pass, pass, and fail depended on the fact that the conditional operator is right associative
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:4| Question number:24
All Answers
total answers (1)
If the operator were left associative, then the expression
would be evaluated as:
which means:
- if the grade is greater than 90, then return
"high pass"
, which is not empty string and evaluate to`true`
, then return"fail"
;- else evaluates
need an explanation for this answer? contact us directly to get an explanation for this answer`grade < 60`
and takes the result as the condition for the second conditional operator, which means if the grade is less than 60, return"fail"
, else return"pass"
.