Tracing a compartment-count array

An Arduino-controlled assembly station stores the number of screws in each of four tray compartments. The following code runs once inside setup():


C++
const int screws[4] = {6, 9, 4, 7};
int total = 0;

for (int i = 0; i < 4; i++) {
  total = total + screws[i];
}


Complete the table with the value read from the array and the total after each iteration. Enter exact integers in screws. Record each total after the addition has executed.

Index iArray value (screws)Total after addition (screws)
0
1
2
3

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Arduino Programming Questions: