Sunday, 23 September 2012

Sum of Array's Elements


#include<iostream>
using namespace std;
const int size = 5;
void main()
{
int a[size];
int sum = 0;

for( int i = 0; i<size; i++)
{
cout<<"enter"<<endl;
cin>>a[i];
sum = sum + a[i];
}
cout<<"sum is: "<<endl;
cout<<sum<<endl;
}

No comments:

Post a Comment