error: variable or field ‘print_array’ declared void

Hello fellow programmers... I'm working on a data operations project and I'm trying to figure out what part of this code I'm writing wrong... I've lookup up the error message online that the online compiler spat back at me but I can't seem to fix my code... still a newb at this so please bear with me. in one inst my teacher said to keep the list labeled list size and in another set she didnt specify..
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
#include <cstdlib>
#include <iostream>

using namespace std;
int even[10]
void print_array int array[], int size)
{
	for(int j = o; j < size; j++)
	{
		cout<< array [j] << "";

	//Check to see if at end of array if so,
	//print a newline
		if(j == (size -1))
			cout << "/n";
	}
}
int main ()
{
	const int LIST1_SIZE = 10; 
	const int LIST2_SIZE = 11;
	
	int [list1_SIZE] = 10{5, 18, 19, 20, 21, 21, 21, 38, 49, 56};
	int [list2_SIZE] = 11{5, 12, 18, 19, 19, 21, 31, 38, 41, 49, 56};
	
	cout << "List 1: " << LIST1_SIZE << " values\n"; 
	cout << "List Values: ";
	print_array(listl, LIST1_SIZE);
	//Do other things

	cout << "List 2: " << LIST2_SIZE << " values\n"; 
	cout << "List Values: ";
	print_array(listl, LIST1_SIZE);
	//Do other things

return  O;
}
There are errors in such a manner which would unlikely appear by coding, so I guess that's your homework.

We won't solve others homework. Not because we are malicious but rather we know that you will learn mostly by solving homework by your own. But I give you some hints:
There are some letters which should be numbers, some variables are wrongly placed, and at line 23/24 the syntax is wrong.
its ok i fiugred it out.....I learned alot about arguments that i didint know about...
#include <cstdlib>
#include <iomanip>
#include <iostream>

using namespace std;

void print_array(int array[], int size)
{
for (int j = 0; j < size; j++)
{
cout << array[j] << " ";

//Check to see if at end of array if so,
//print a newline
if (j == (size - 1))
cout << "\n";
}
}
//Calculates the Mean of the array
double calcMean(int size, int list[])
{
if (size <= 0)
return 0;
int sum = 0;
for (int i = 0; i < size; i++)
sum += list[i];
return (double)sum / size;
}
//Calculates the Median of the array
double calcMedian(int size, int list[])
{
// sort if not sorted.
// in this example not needed
if (size <= 0)
return 0;
if (size % 2 != 0)
return (double)list[size / 2];
else
return (double)(list[(size - 1) / 2] + list[size / 2]) / 2.0;
}
//Calculates the Mode of the array
int calcMode(int size, int list[])
{
// sort if not sorted.
// in this example not needed
if (size <= 0)
return 0;
int counter = 0;
int max = 0;
int mode = list[0];
for (int i = 0; i < size - 1; i++)
{
if (list[i] == list[i + 1])
{
counter++;
if (counter > max)
{
max = counter;
mode = list[i];
}
}
else
{
counter = 1;
}
}
return mode;
}
//Calculates the Range of the array
int calcRange(int size, int list[])
{
if (size <= 0)
return -1;
int max, min;
max = min = list[0];
for (int i = 1; i < size; i++)
{
if (list[i] > max)
max = list[i];
if (list[i] < min)
min = list[i];
}
return max - min;
}
//This main displays alll the characters for the program. The top of the list as well as all teh values shown
int main()
{

cout << fixed << setprecision(1);
const int EVEN_SIZE = 10, ODD_SIZE = 11;

int evenNumList[EVEN_SIZE] = { 5,18,19,20,21,21,21,38,49,56 };
int oddNumList[ODD_SIZE] = { 5,12,18,19,19,21,31,38,41,49,56 };

cout << "List 1: " << EVEN_SIZE << " values\n";
cout << "List Values: ";
print_array(evenNumList, EVEN_SIZE);

cout << "Mean of the List: " << calcMean(EVEN_SIZE, evenNumList) << endl;
cout << "Median of the List: " << calcMedian(EVEN_SIZE, evenNumList) << endl;
cout << "Mode of the List: " << calcMode(EVEN_SIZE, evenNumList) << endl;
cout << "Range of the List: " << calcRange(EVEN_SIZE, evenNumList) << endl;

cout << endl;

cout << "List 2: " << ODD_SIZE << " values\n";
cout << "List Values: ";
print_array(oddNumList, ODD_SIZE);

cout << "Mean of the List: " << calcMean(ODD_SIZE, oddNumList) << endl;
cout << "Median of the List: " << calcMedian(ODD_SIZE, oddNumList) << endl;
cout << "Mode of the List: " << calcMode(ODD_SIZE, oddNumList) << endl;
cout << "Range of the List: " << calcRange(ODD_SIZE, oddNumList) << endl;

return 0;
}



Topic archived. No new replies allowed.