CJCoding With Joseph
15free / daySign inCreate account

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

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Exceptions
📥 Auto-Input:
200\n
This input is automatically fed to your program's stdin
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.