You learn by trying. If there are parts of the program that you do not understand look them up, or ask about them here. The program starts on the first line in main() so I suggest starting there, make sure you understand what each line is doing, and keep track of what the output is.
Put the code into a file (or use an IDE), compile it, run it and see what is displayed. Then if you don't understand, use the debugger to trace through the code to see what is happening, and then if you don't understand a particular line, then ask.