program to find the sum of element of given array

 #include <iostream>

using namespace std;
// funtion to reverse the array
void reverse(int arr[],int size){
int start = 0;
int end = size-1;

while (start<=end)
{
swap(arr[start],arr[end]);
start++;
end--;

}
}

// funtion to find the sum of elements of array;
int sum = 0;
void addingarray(int arr[],int size){
for (int i = 0; i < size; i++)
{
sum = sum+arr[i];
}
cout<<endl;
}
int main(){


int marray[5]={3,5,6,7,8};
addingarray(marray,5);
cout<<sum;

}

Comments

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

Learning stage | c++ programs

c++ basic question