โ Back to Exceptions
Question 665
Identify The Exception Type
Identify The Exception Type
Read an integern. Ifn == 0, throw aDivideByZeroException; ifn < 0, throw anArgumentException; otherwise printValue: <n>. Use a singlecatch (Exception ex)that catches any of them and printsCaught: <ex.GetType().Name>. Use top-level statements. Input5prints: Value: 5 Input0prints: Caught: DivideByZeroException Input-1prints: Caught: ArgumentException
Expected Output:
Value: 5
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.