Check out example codes for "sum of elements in c++ stl". It will help you in understanding the concepts better.

Code Example 1

accumulate(a.begin(), a.end(), 0)

Learn ReactJs, React Native from akashmittal.com