If you know about function calls, global, static, and local variables, and the fork command, it is fairly straightforward to determine the output of the program, which I assume is your assignment. Look up these topics in your textbook or notes.

Converting the program to Java seems odd to me. Does Java have a fork command? (Windows doesn't.)