First, you should make sure it compiles cleanly and runs cleanly with memory checkers. Clean means no errors and no warnings. For example, gcc -g -Wall -std=c99 code.c -o output -lmcheck ; valgrind -q ./output.
Second, you should test your code with all possible inputs. Being creative about choosing good test cases is part of good programming. Try large inputs and inputs that exercise every branch of your program.