Write a function that takes an array of integer elements


Problem

This is C++ programming I need help writing a function that takes an array of integer elements as the input parameter and returns the largest element of the array.*/ Like user inputs some numbers then the largest number is shown. This is what I have but I cannot remember how to declare/initialize arr or size and where to put it.

#include
using namespace std;
void printArray(int[], int);
int i = 0;
int main()
{
int printArray(int arr[], int size); {
int max = arr[0];
int sum = arr[0];
for (int i = 1; i < size; i++) {
if (max < arr[i]) {
max = arr[i];
}
sum += arr[i];
}
cout << "Average = " << (1.0 * sum / size) << endl;
return max;
}
}
void printArray(int[], int)
{
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a function that takes an array of integer elements
Reference No:- TGS03255410

Expected delivery within 24 Hours