Demonstrate accumulate() in vector
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
vector<int> vectorObject(5);
int i, total;
for(i = 0; i < 5; i++)
vectorObject[ i ] = i;
total = accumulate(vectorObject.begin(), vectorObject.end(), 0);
cout << "Summation of vectorObject is: " << total;
return 0;
}
Related examples in the same category