Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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; 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started