1 vector<int> v{1,2,3,4,5,6,7,8,9};
2 int sum = 0;
3//Method 1:
4 sum = accumulate(v.begin(), v.end(), 0);
5//Method 2:
6 for(auto& i : v) sum+=i;
1 // Sum digits in vector
2int digit_sum(vector<int> num) {
3 int sum = 0;
4 for (auto x : num) sum += x;
5 return sum;
6}