Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ add everything in a vector

#include<vector>
#include<numeric>
using namespace std;
int main() {
   vector<int> v = {2,7,6,10};
   cout<<"Sum of all the elements are:"<<endl;
   cout<<accumulate(v.begin(),v.end(),0);
}
/* Output
Sum of all the elements are:
25
*/
 
PREVIOUS NEXT
Tagged: #add #vector
ADD COMMENT
Topic
Name
6+7 =