Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ find sum of vector

#include<iostream>
#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);
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #find #sum #vector
ADD COMMENT
Topic
Name
7+7 =