basics · beginner · ~15 min
Reason about the range of a fixed-width type.
Implement int fits_in_uint8(int n) returning 1 if n is in the range 0..255 (the range of an unsigned 8-bit value), else 0.
int fits_in_uint8(int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.