The program below has a problem. Which statement correctly describes it?
#include <stdio.h>
int sign(int x) {
if (x > 0)
return 1;
if (x < 0)
return -1;
}
int main(void) {
printf("%d\n", sign(0));
return 0;
}
Falling off the end of a non-void function is allowed, but using the "result" is undefined: you may see 0, garbage or a crash. Compilers warn (-Wreturn-type). Add return 0; at the end.