On unix, system() (which is a standard function) will return the termination status of whatever you're running. But remember that you only get 8 bits for the return value, so you can only return values 0-255.

Again assuming unix, you could have one program print out a number and then the other program use popen() to grab the output and parse it. This is somewhat analogous to using `` or $() in the Bourne shell; it just takes a bit more work to do.