Getting the total amount of items sold

I am writting a program where I enter in the product number and the number of items sold of a product. This action is repeated until the input (-1) is entered. I have the program running fine. The problem is I cannot get the program to display the total amount of items sold at the end of the program. It only shows me the most recent data entered. Can anyone help?
closed account (zb0S216C)
You have to show us the code so we can see how you've implemented it.

Wazzak
Just keep a counter?

1
2
3
4
5
int total_items_sold = 0;
// In selling code:
total_items_sold += items_sold;
// At end:
cout << "We sold " << total_items_sold << " items!" << endl; 
Change the program!
Thanks guys... I am seriously a novice and was making this way too complicated! All the If's and else if's were throwing me off. The counter helped and now it's working perfectly!
Topic archived. No new replies allowed.