Software Design Using C++Review of Decision StatementsAnswering the QuestionFirst, we repeat the description of the problem: Write a C++ function that is given an integer grade (such as 90, 84, 66) and sends back the corresponding letter grade (such as A, B, D) in the function name. Return the letter I for any invalid grade number. You selected Answer C, shown below. This is incorrect. Consider, for example, the value of 77 for NumGrade. The section of code below first assigns the value 'C' to Ch, then assigns 'D' to Ch, then assigns 'F' to Ch. Thus, when Ch is returned, it is the 'F' that is returned. In fact, this function always returns an 'F', except in the case of negative values (for which it returns an 'I'). Go back and see if you can find the correct answer.
You can go back to the overall review listing: Review of Introductory Topics. Back to the main page for Software Design Using C++ |