The fitness band saved each day's steps. Write total_steps(steps, n) to add up n days. The loop moves a pointer p from the first day to the last; you just add what p points to into total. When n is 0 it gives 0.
total_steps({3000, 4500, 5200}, 3)→12700total_steps({800}, 1)→800int total_steps(int *steps, int n)int total_steps(int *steps, int n) {
int total = 0;
for (int *p = steps; p < steps + n; p++) {
// your code here: add the steps p points to into total
}
return total;
}
Run tries the examples. When they look right, Submit.