basics · beginner · ~15 min
Branch on a value's sign.
Implement int sign_of(long n) returning -1, 0, or 1 for negative, zero, and positive n.
int sign_of(long n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.