I would like to know if there is anyway to perform Sum of a vector till specific index using accumulate(). Example
vector<int> v ={1,2,3,4,5,6};
int sum = accumulate(v.begin(), till_index_4, 0);
All examples i found says accumulate(v.begin(), v.end(), 0); I tried with iterator also but my code is not compiled. Please let me if there is any possible solutions available.