#include<iostream>
using namespace std;
int main()
{
int n,i,sum=0;
int arr[10];
cout<<"enter the size of array:?";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"enter the array digit:";
cin>>arr[i];
}
for(i=0;i<n;i++)
{
sum=sum+arr[i];
}
cout<<"sum of array is:"<<sum<<endl;
return 0;
}
using namespace std;
int main()
{
int n,i,sum=0;
int arr[10];
cout<<"enter the size of array:?";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"enter the array digit:";
cin>>arr[i];
}
for(i=0;i<n;i++)
{
sum=sum+arr[i];
}
cout<<"sum of array is:"<<sum<<endl;
return 0;
}
Tags:
C++ Programs