Check this thread:Prime number algorithm in C
http://www.thescripts.com/forum/thread215055.html
Then you can check whether it is a prime number starting from the user input.
Say, if the user inputs 100, you can start checking from 100, to 99, then 98, then 97...
The loop should stop when the prime number method returns zero.
There you go, you get the answer:)