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