Do yourself a favor and break that down into several, smaller functions, each with a clearly define responsibility. Having your entire program in one gigantic main function will quickly get out of...