Question: Code Example 11-2 struct Invalidsize { string message; int size; double get,average (double sales [1, int size) { if (size Invalidsizeerror; error.message = Error! Size

 Code Example 11-2 struct Invalidsize \{ string message; int size; doubleget,average (double sales [1, int size) \{ if (size Invalidsizeerror; error.message ="Error! Size must be >0."; error.size = size; throw error; \} double

Code Example 11-2 struct Invalidsize \{ string message; int size; double get,average (double sales [1, int size) \{ if (size Invalidsizeerror; error.message = "Error! Size must be >0."; error.size = size; throw error; \} double total = accumulate (sales, sales + size, 0.0); double average = total / size; return average; (Refer to Code Example 11 -2.) What happens when the following code is executed? double sales [5]={74.58,52.43,66.89,37.57,43.21}; try \{ double average = get_average ( sales, 0); \} catch() I cout "An unexpected exception occurred! "; throw; \} The message: (A) An unexpected exception occurred! is displayed at the console and an exception object created from the exception class is thrown to the calling code. The message: (B) An unexpected exception occurred! is displayed at the console and an exception object created from the InvalidSize structure is thrown to the calling code. (C) A compile-time error occurs because the catch clause isn't properly coded. (D) A runtime error occurs because the InvalidSize exception isn't caught

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!