lots of code snippets can be found on the net to check if a given input is prime, here's a few from a quick search
http://holmezideas.com/programming/optimization-techniques/fastest-algorithm-to-check-if-a-given-number-is-prime/
http://www.programmingsimplified.com/c/source-code/c-program-for-prime-number