Identify The Exception Type
mediumQuestion 755Read an integer n. If n == 0, throw a DivideByZeroException; if n < 0, throw an ArgumentException; otherwise print Value: <n>. Use a single catch (Exception ex) that catches any of them and prints Caught: <ex.GetType().Name>. Use top-level statements.
Input 5 prints: Value: 5
Input 0 prints: Caught: DivideByZeroException
Input -1 prints: Caught: ArgumentException
Expected output
Value: 5= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.