PROGRAM
//A simple program to perform the addition of elements of an array
# include <iostream>
using namespace std;
int main()
{
int a[5] , i , sum=0 ;
cout<<"INPUT THE ARRAY ELEMENTS:\n";
for(i=0;i<5;i++)
{
cout<<"a["<<i<<"]=";
cin>>a[i];
}
for(i=0;i<5;i++) //Loop for addition
{
sum=sum+a[i];
}
cout<<"SUM IS:"<<sum;
return 0;
}
OUTPUT
//A simple program to perform the addition of elements of an array
# include <iostream>
using namespace std;
int main()
{
int a[5] , i , sum=0 ;
cout<<"INPUT THE ARRAY ELEMENTS:\n";
for(i=0;i<5;i++)
{
cout<<"a["<<i<<"]=";
cin>>a[i];
}
for(i=0;i<5;i++) //Loop for addition
{
sum=sum+a[i];
}
cout<<"SUM IS:"<<sum;
return 0;
}
OUTPUT