Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

sum vector c++

  vector<int> v{1,2,3,4,5,6,7,8,9};
  int sum = 0;
//Method 1:
  sum = accumulate(v.begin(), v.end(), 0);
//Method 2: 
  for(auto& i : v) sum+=i;
 
PREVIOUS NEXT
Tagged: #sum #vector
ADD COMMENT
Topic
Name
5+4 =