partial_sum

template<class InIt, class OutIt>
    OutIt partial_sum(InIt first, InIt last,
        OutIt result);
template<class InIt, class OutIt, class Pred>
    OutIt partial_sum(InIt first, InIt last,
        OutIt result, Pred pr);

The first template function stores successive values beginning at result, for each value of the InIt iterator I in the interval [first, last). The first value val stored (if any) is *I. Each subsequent value val stored is val + *I. The function returns result incremented last - first times.

The second template function stores successive values beginning at result, for each value of the InIt iterator I in the interval [first, last). The first value val stored (if any) is *I. Each subsequent value val stored is pr(val, *I). The function returns result incremented last - first times.

See the related sample program.