c++ vector assign the last elemnt as a sum of all other elemnts code example Example: sum of vector c++ accumulate(a.begin(), a.end(), 0);