int sum_array(int* array,int start, int end) { int i = start; int res = 0; while (i != end) { res += array[i]; i++; } return res; } int main() { int array[10] = { 2,6,9,4,2,64,5,9,54,3 }; int A = 3; int B = 8; int Sum = sum_array(array,A,B); //sum is 138! }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)