Help with function

.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;
const int YEARS = 3;
void computeMaximum(int data[], int& q);

int main()
{
	int num[3] = { 5, 6, 20 };
	int maximum = 0;
	computeMaximum(num, maximum);
	cout << maximum;

	return 0;
}
void computeMaximum(int data[], int& q)
{
	int comp = data[0];
	for (int k = 1; k < YEARS; k++)
	{
		if (comp < data[k])
		{
			comp = data[k];
			q = k; //<-- removed int
		}
	}
}
Topic archived. No new replies allowed.