- Code: Select all
for (i=0; i <=numbers; i++)
total += amount[i];
cout << "total =" << total << endl;
After asking for a single amount you then create a loop to (presumably) go through every amount and add it to total. The first problem being that you only have one "amount" value at this time so using a for loop is wrong; the second problem is that you are trying to treat amount as an array but it isn't an array, it's just a single number.
You also have another unrelated problem: you're doing i++ twice, once in the for declaration and again within the loop itself. In fact, using "i" there as your counter is entirely wrong because you're already using it to count the bigger while loop. Just get rid of that for loop, you don't need it. Replace with simple "total += amount;" and you should be fine.