I am currently trying to understand why this example for using an array as an argument in a function has a different result than what the lecture notes say it should be.

So supposedly sum should return with the value 28, but I get 27 no matter what. I also am not very good at reading and understanding what exactly the order of operations for this function are, if someone would be willing to help me I would greatly appreciate it

Code:

#include <iostream>
using namespace std;
int sum(const int array[], const int length) {
long sum = 0;
for (int i = 0; i < length; sum += array[++i]);
return sum;
}
int main() {
int arr[] = {1, 2, 3, 4, 5, 6, 7};
cout << "Sum: " << sum(arr, 7) << endl;
return 0;
}