Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Run the program. The program should display the total amount in inventory, but i

ID: 3804027 • Letter: R

Question

Run the program. The program should display the total amount in inventory, but it is not working correctly. Debug the program. in c++

#include <iostream>
using namespace std;

int main()
{
   int inventory[10] = {34, 50, 75, 65, 89,
                       50, 25, 48, 35, 67};
   int total = 0;

   for (int sub = 1; sub < 10; sub += 1)
       total =+ inventory[sub];
   //end for
   cout << "Total amount in inventory: " << total << endl;
   return 0;
}   //end of main function

Explanation / Answer

Below is the required debugged code:-

Thank you.