Answers for "C++ sum a vector of digits"

C++
14

sum of vector c++

accumulate(a.begin(), a.end(), 0);
Posted by: Guest on May-17-2020
0

C++ sum a vector of digits

// Sum digits in vector
int digit_sum(vector<int> num) {
    int sum = 0;
    for (auto x : num) sum += x;
    return sum;
}
Posted by: Guest on April-21-2021

Browse Popular Code Answers by Language