Answers for "c++ sum of a loop"

7

sum of elements in c++ stl

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

sum array c++

array<int,10> a{1,2,3,4,5,6,7,8,9};
  int sum = 0;
//Method 1:
  sum = accumulatea(a.begin(), a.end(), 0);
//Method 2: 
  for(auto& i : a) sum+=i;
Posted by: Guest on June-05-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language