There's no problem with putting code after main. The problem is the loop that waits for ode is top-level code, meaning it is not inside of any of your functions, top-level code is always executed first, even before main(), then the code in main() is executed. There is no reason for two main...