You may want to use Perl, but that's my own personal bias

This is a good reference for shell scripting, probably contains what you are looking for. Its advanced stuff that may be helpful, you're simply:
1. searching every directory for *.c files
2. compiling and executing the *.c files
3. storing the output and comparing them

It doesn't sound too hard, the hardest part would be getting the output (only because I don't know how to do it).