Array Sum
Array Sum
Send Feedback
Array Sum
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spaces
Sum
3
9 8 9
26
#include<iostream>using namespace std;
int main(){ int n,sum=0; //cout<<"Entr the value of n:"<<" "; cin>>n; int array[n]; for(int i=0;n>i;i++){ cin>>array[i]; } // for(int i=0;n>i;i++){ // cout<<array[i]<<" "; // } for(int i=0;n>i;i++){ sum+=array[i]; } cout<<endl<<sum; /* Read input as specified in the question. * Print output as specified in the question. */ }
Comments
Post a Comment