CJCoding With Joseph

Overflow On Byte Cast

Read an integer n and convert it to a byte using checked((byte)n), then print Byte: <b>. A byte holds 0 to 255; in a checked cast, a value outside that range throws an OverflowException. Catch it and print Too large for byte. Use top-level statements.

Input 200 prints: Byte: 200
Input 300 prints: Too large for byte

Expected Output:

Byte: 200
Topics:
Exceptions
๐Ÿ“ฅ Auto-Input:
200\n
This input is automatically fed to your program's stdin
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.