stl accumulate in c++ code example
Example: accumulate c++
#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
}