Sum Of Array In C++

#include<iostream>
using namespace std;
int main()
{
    int n,i,sum=0;
    int arr[10];
    cout<<"enter the size of array:?";
    cin>>n;
    for(i=0;i<n;i++)
    {
        cout<<"enter the array digit:";
        cin>>arr[i];
    }
    for(i=0;i<n;i++)
    {
        sum=sum+arr[i];
    }
    cout<<"sum of array is:"<<sum<<endl;
    return 0;
}

Post a Comment

Previous Post Next Post