Facebook
From 210505, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 96
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4.  
  5. {
  6.    int arr[100],i,n,sum=0;
  7.    cout<<"Enter the number of elements: ";
  8.    cin>>n;
  9.    cout<<"Enter the value of elements: "<<endl;
  10.    
  11.    for(i=0;i<n;i++)
  12.    {
  13.      cin>>arr[i];
  14.    }
  15.  
  16.    for(i=0;i<n;i++)
  17.    {
  18.     sum=sum+arr[i];
  19.    }
  20.     cout<<"Sum of elements in an array is: "<<sum;
  21.  
  22.     return 0;
  23. }