fork download
  1. #include <iostream>
  2. #include <numeric>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double fArr[] = {-325.33, -0.9, 0.85, -10.55, 5000.56, 52.2};
  8.  
  9. double fSumAccum = accumulate(fArr, fArr+sizeof(fArr)/sizeof(double), 0);
  10.  
  11. double fSumLoop = 0.0;
  12. for (size_t i = 0; i < sizeof(fArr)/sizeof(double); i++)
  13. fSumLoop += fArr[i];
  14.  
  15. cout << "fSumAccum = " << fSumAccum << ", " << "fSumLoop = " << fSumLoop << endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 2684KB
stdin
Standard input is empty
stdout
fSumAccum = 4718, fSumLoop = 4716.83