how to return the sum of a vector array and size in c++ code example
Example: 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;
}
// Sum digits in vector
int digit_sum(vector<int> num) {
int sum = 0;
for (auto x : num) sum += x;
return sum;
}