I just started playing around with C++ with Xcode, but this happened to me when I run the code, the line "Program ended with exit code: 0" appear towards in the beginning of the output. Please help me to fix it.
If that message is indeed before your program's "output" then is probably from your compiler/linker telling you that your program compiled and linked properly.
If that message is at the end of the program's "output" then it is just telling you that your program ended normally.