#include<iostream>#include<vector>#include<numeric>usingnamespace std;intmain(){
vector<int> v ={2,7,6,10};
cout<<"Sum of all the elements are:"<<endl;
cout<<accumulate(v.begin(),v.end(),0);}
//Syntaxaccumulate(first, last, sum);accumulate(first, last, sum, myfun);
first, last : first and last elements of range
whose elements are to be added
sum : initial value of the sum
myfun : a function for performing any
specific task. For example, we can
find product of elements between
first and last.//Exampleint a[]={5,10,15};int res =accumulate(a,a+3,0);// 30