stl sum code example
Example 1: sum of vector c++
accumulate(a.begin(), a.end(), 0);
Example 2: accumulate() in c++
accumulate(first, last, sum);
first, last : first and last elements of range
whose elements are to be added
suppose array is 'a'.
sum : initial value of the sum
Eg: int sum=0;
accumulate(a.begin(),a.end(),sum);
Example 3: accumulate in cpp
accumulate(start, end, initial_sum);