Selecting response times from an array

A diagnostic script selects response times that are exact multiples of 2 ms. Trace this C code and give the final count, total in milliseconds, and i. Enter all three as exact integers.


C
int times[6] = {5, 12, 7, 16, 9, 20};
int count = 0;
int total = 0;
int i = 0;

for (i = 0; i < 6; i++) {
    if (times[i] % 2 == 0) {
        count++;
        total += times[i];
    }
}
Your answers

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 Data and Control Structures in C Questions: