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..
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.
//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()
{