using namespace std;
int main ()
    int arr[14], n, i, sum = 0;
    cout << "Enter the size of the array : ";
    cin >> n;
    cout << "\nEnter the elements of the array : ";
    for (i = 0; i < n; i++)
    cin >> arr[i];
    for (i = 0; i < n; i++)
        sum += arr[i];

    cout << "\nSum of array elements : " << sum;

    return 0;

Recommended Answers

All 3 Replies

Please, I need help urgently

It’s hard for anyone to help you because you’re not really describing what your problem is. Is the code you provided not working? Are you getting any error messages? Your topic title says to write an algorithm and then you just posted a bunch of code. We are confused how we can help.

I ran your code at https://www.onlinegdb.com/online_c++_compiler and it ran fine and produced the sum of the Integers I put in.

Your code however is needlessly complicated I could do this without the array!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.