how to add integers from 0 to n in c++ vector code example
Example 1: sum of elements in c++ stl
accumulate(a.begin(), a.end(), 0)
Example 2: sum elements in vector c++
for (auto& n : vector)
sum_of_elems += n;
accumulate(a.begin(), a.end(), 0)
for (auto& n : vector)
sum_of_elems += n;