Program to find sum of elements in a given array | C ++ Program to find sum of elements in a given array ; Driver code ; calling accumulate function , passing first , last element and initial sum , which is 0 in this case .
#include <bits/stdc++.h> NEW_LINE using namespace std ; int main ( ) { int arr [ ] = { 12 , 3 , 4 , 15 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << " Sum ▁ of ▁ given ▁ array ▁ is ▁ " << accumulate ( arr , arr + n , 0 ) ; return 0 ; }