This is supposed to prompt the user to enter sales for each month and then calculate yearly totals, then finally a total sales figure. I have only done the first year calculation but after the program runs it calculates year one sales then crashes saying:
program terminated with status -1073741819
debugger gives me an error on line 47 which is the return 0; line. I'm not sure what is wrong. Any help would be awesome.
Remember that arrays are ranged from [0,X)... not [1,X] This means that if you have an array of size [3], valid indexes are [0], [1], and [2]. Index [3] is out of bounds.
Lin 31:
for (int year = 1; year <= 3; ++year)
This means you'll be using indexes 1, 2, and 3.. which is wrong. You probably want to change this to the below:
for (int year = 0; year < 3; ++year)
Note you start at ZERO (not at 1), and you loop while you're LESS THAN (not <=) three.
Similar problem on line 43:
YearOneSales += MonthlySales[j][1];
While this isn't "wrong" in the same sense that the above code was... it's probably not what you wanted. You probably wanted year [0] here... not year [1].