C++ 23 · Containers and algorithms
Sum a range
Add up the elements, starting from 0.
#include <numeric>
int total = std::accumulate(v.begin(), v.end(), 0);
C++ 23 · Containers and algorithms
Add up the elements, starting from 0.
#include <numeric>
int total = std::accumulate(v.begin(), v.end(), 0);
Was this page helpful?