Computer Science, asked by mahanandipappu, 5 months ago

Wap to intialize the given data in array and find the minimum and maximum values along with the sum of the given elements .. And also write the given elements.

Sample output : 2 5 4 1 3

Output : maximum value - 1 ,

maximum - 2 , sum - 15

Answers

Answered by pari2008chitra61
0

Explanation:

Examples :

Input : arr[] = {1, 2, 3}

Output : 6

1 + 2 + 3 = 6

Input : arr[] = {15, 12, 13, 10}

Output : 50

Recommended: Please solve it on “PRACTICE ” first, before moving on to the solution.

/* C++ Program to find sum of elements

in a given array */

#include <bits/stdc++.h>

using namespace std;

// function to return sum of elements

// in an array of size n

int sum(int arr[], int n)

{

int sum = 0; // initialize sum

// Iterate through all elements

// and add them to sum

for (int i = 0; i < n; i++)

sum += arr[i];

return sum;

}

// Driver code

int main()

{

int arr[] = {12, 3, 4, 15};

int n = sizeof(arr) / sizeof(arr[0]);

Similar questions