accum2.cpp

accum2.cpp

#include ‹stl.h›

#include ‹iostream.h›

int mult(int initial_, int element_) {

 return initial_ * element_;

}

int main() {

 vector‹int› v(5);

 for (int i = 0; i ‹ v.size(); i++) v[i] = i + 1;

 int prod = accumulate(v.begin(), v.end(), 1, mult);

 cout ‹‹ "prod = " ‹‹ prod ‹‹ endl;

 return 0;

}