Stupid newbie c++ two-dimensional array problem.
- by paulson scott
I've no idea if this is too newbie or generic for stackoverlflow. Apologies if that's the case, I don't intend to waste time.
I've just started working through C++ Primer Plus and I've hit a little stump. This is probably super laughable but:
for (int year = 0; year < YEARS; year++)
{
cout << "Year " << year + 1 << ":";
for (int month = 0; month < MONTHS; month++)
{
absoluteTotal = (yearlyTotal[year][year] += sales[year][month]);
}
cout << yearlyTotal[year][year] << endl;
}
cout << "The total number of books sold over a period of " << YEARS << " years is: " << absoluteTotal << endl;
I wish to display the total of all 3 years. The rest of the code works fine: input is fine, individual yearly output is fine but I just can't get 3 years added together for one final total.
I did have the total working at one point but I didn't have the individual totals working. I messed with it and reversed the situation. I've been messing with it for God knows how long.
Any idea guys? Sorry if this isn't the place!