Generation

generate functionSun, 13 Nov 2022

Add every other number in a vector

int AddEveryOther(int *vec, int size) { int sum = 0; for (int i = 0; i < size; i = i + 2) { sum = sum + vec[i]; } return sum; }

Questions about programming?Chat with your personal AI assistant