Array Program Please Help

So I get the error: "argument of type int is incompatible of type int" and I have tried many things already.

1
2
3
4

	highlowavgFunc(even[50], odd[50]);
	maxthanavgFunc(even[50], odd[50]);


Any suggestions?
It seems you transfered a wrong type to the function(like unsigned int to signed and int).you need give us the declaration of the two functions. Or we know nothing about it.
alright so I need to declare that type to the function correct?
the full error was "argument of type int is incompatible with parameter of type int"
Are you trying to send the function a single element of the array or the entire array?
entire array
When you're going to send an entire array, just use the name of the array. Don't use the [] in the function call.

Did that error message have an int vs an int*? It sounds like the function is expecting a whole array (int*) but you're sending it an individual element (int).
do you want to see the whole program?
How are these functions defined?

highlowavgFunc(even[50], odd[50]);
maxthanavgFunc(even[50], odd[50]);
yes and the error message did have an int*
Updated Code
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

ifstream infile; ofstream outfile;

void highlowavgFunc(int even[], int odd[]);
void maxthanavgFunc(double&, double&, int even[], int odd[]);

int main()
{
	int even[50], odd[50];
	double avgeven, avgodd;
	infile.open("c:\\Users\\Tony\\Documents\\data2.txt");
	if (!infile)
	{
		cout << "Error file not found." << endl;
		system("pause");
		exit(1);
	}
	else
		cout << "Success!" << endl;

	outfile.open("c:\\Users\\Tony\\Documents\\array.txt");

	while (infile)
	{
		for (int i = 0; i < 50; i++)
			infile >> even[i];
		for (int i = 0; i < 50; i++)
		{
			if (even[i] % 2 != 0)
			{
				odd[i] = even[i];
			}
		}

	}

	highlowavgFunc(even, odd);
	maxthanavgFunc(avgeven, avgodd, even, odd);

	infile.close();
	outfile.close();

	system("pause");
	return 0;
}

//Find the min, max, total, and average
void highlowavgFunc(int e[], int o[])
{
	
	int maxeElement = -10;
	int maxoElement = -10;
	int mineElement = -10;
	int minoElement = -10;
	int eventotal = 0;
	int oddtotal = 0;
	int me, mo, Me, Mo, Ae, Ao;

	for (int element = 0; element < 50; element++)
	{
		if (e[maxeElement] < e[element])
			maxeElement = element;
		if (o[maxoElement] < o[element])
			maxoElement = element;
		if (e[mineElement] > e[element])
			mineElement = element;
		if (o[minoElement] > o[element])
			minoElement = element;
	}
	me = e[maxeElement];
	outfile << "Max Even: " << me << endl;
	mo = o[maxoElement];
	outfile << "Max Odd: " << mo << endl;

	Me = e[mineElement];
	outfile << "Min Even: " << Me << endl;
	Mo = o[minoElement];
	outfile << "Min Odd: " << Mo << endl;

	for (int element = 0; element < 50; element++)
	{
		eventotal = eventotal + e[element];
		oddtotal = oddtotal + o[element];
	}

	Ae = eventotal / 29;
	outfile << "This is the average for the even array: " << Ae << endl;
	Ao = oddtotal / 21;
	outfile << "This is the average for the odd array: " << Ao << endl;
}

//Find a number higher than the average
void maxthanavgFunc(double& Ae, double& Ao, int e[], int o[])
{
	int element;

	outfile << "These numbers are higher than their respective averages: ";
	for (element = 0; element < 50; element++)
	{
		if (e[element] > Ae)
			outfile << e[element] << "\t";
		if (o[element] > Ao)
			outfile << o[element] << "\t";
	}
	outfile << endl;
}


Ok this works yet now I get some huge random negative number in my ouput....
Last edited on
Topic archived. No new replies allowed.