Check out example codes for "accumulate c++". It will help you in understanding the concepts better.

Code Example 1

#include <numeric> // Accumulate
#include <vector> // Vector 
using namespace std;

int main()
{
  vector<int> nums{1,2,3,4,5};
  int sum = 0;
  sum = accumulate(nums.begin(), nums.end(), sum);
  // nums.begin() -> first number in a list 
  // nums.end() -> last number in a list 
  // sum -> starting value before accumulating: Here its 0
}

Code Example 2

accumulate(start, end, initial_sum);

Code Example 3

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);

Code Example 4

accumulate(first, last, sum, myfun); 
myfun : a function for performing any 
        specific task. For example, we can
        find product of elements between
        first and last.

Code Example 5

accumulate(first, last, sum);
first, last : first and last elements of range 
              whose elements are to be added
sum :  initial value of the sum

Learn ReactJs, React Native from akashmittal.com