Finding largest number in array that is passed to the function

I have an assignment where I have to pass the array to a function then use that function to find and output the largest number. I feel like I am close but I have been stumped on this for hours now and can't get a response out of my teacher. Any help would be GREATLY appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>
using namespace std;

int main(){

int thearray[3]={54,25,63};

findarrmax(int thearray,3);
}


void findarrmax(int thearray[], int i)

int max = thearray[0];

for (int i=1;i<array;i++)
{
if(max<array[i])
max=array[i];
}
return max;

Last edited on
Line 3: You need a forward declaration for findarrmax.

Line 8: Lose the int.

Line 8: Your call to findarrmax finds the largest value, but you ignore the result returned by your function.

Lines 16,18,19: array is not defined. Your argument name is thearray.

Line 16: Your loop termination condition is wrong.
Topic archived. No new replies allowed.