
June 4, 1996. Ariane 5 lifts off on its maiden flight, carrying four science satellites. Thirty-seven seconds in, the guidance system tries to stuff a 64-bit velocity into a signed 16-bit integer. It does not fit, the conversion overflows, the navigation computer chokes on the garbage that comes out, and the rocket swerves and self-destructs. Price of that one unchecked conversion: about 370 million dollars. Catch the overflow before it happens.
Objective
Read a value and print it only if it fits in a signed 16-bit integer, otherwise print OVERFLOW.
Steps
$ ./main 32767
32767
$ ./main 32768
OVERFLOW
$ ./main -32768
-32768
Expected files
Allowed functions
Loading solutions...