fork download
  1. using namespace std;
  2.  
  3. int arraySum(int a[], int n)
  4. {
  5. int initial_sum = 0;
  6. return accumulate(a, a+n, initial_sum);
  7. }
  8.  
  9. int main()
  10. {
  11. int a[] = {11 , 5 , 66} ;
  12. int n = sizeof(a)/sizeof(a[0]);
  13. cout << arraySum(a, n);
  14. return 0;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int arraySum(int*, int)’:
prog.cpp:6:12: error: ‘accumulate’ was not declared in this scope
     return accumulate(a, a+n, initial_sum);
            ^~~~~~~~~~
prog.cpp: In function ‘int main()’:
prog.cpp:13:5: error: ‘cout’ was not declared in this scope
     cout << arraySum(a, n);
     ^~~~
prog.cpp:13:5: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
prog.cpp:1:1:
+#include <iostream>
 using namespace std;
prog.cpp:13:5:
     cout << arraySum(a, n);
     ^~~~
stdout
Standard output is empty