Horje
accumulate c++ Code 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
}




Cpp

Related
rotate in cpp Code Example rotate in cpp Code Example
convert decimal to binary in c++ Code Example convert decimal to binary in c++ Code Example
what is the associative property of an operator Code Example what is the associative property of an operator Code Example
rotate in c++ Code Example rotate in c++ Code Example
c++ return multiple values Code Example c++ return multiple values Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8