#include <bits/stdc++.h>
using namespace std;
class solution{
public:
int arraySum(int arr[], int n){
//Write your code here...
int s=0;
for(int i = 0; i < n; i++) {
s = arr[i] + s;
}
return s;
}
};
int main(){
solution obj;
int n;
cout<<"enter length arr"<<endl;
cin>>n;
int arr[n];
cout << "enter no.s" << endl;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int total = obj.arraySum(arr, n);
cout << "Sum is: " << total << endl;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: