Skip to content

Commit

Permalink
sum of array elements
Browse files Browse the repository at this point in the history
  • Loading branch information
FazeelUsmani authored Nov 9, 2019
1 parent eae6037 commit eae7cd4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 003 Sum of array elements.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
//int t,i;
long int n,t,i;
cin>>t;
while(t--)
{
cin>>n;
long int sum = 0, a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
sum+=a[i];
}
cout<<sum<<"\n";
}

return 0;
}

0 comments on commit eae7cd4

Please sign in to comment.