expected primary expression error with xcode
Be patient with me please, I'm a serious noob.
This is for an intro C++ class. The assignment is to design and implement a program that will accept up to twenty-five integers. It must include the following functions:
* An input function that fills the array
* A function that finds and displays the average of the even numbers in the collection.
* A function that finds and displays the average of the odd numbers in the collection.
I keep getting this error: "error: expected primary-expression before ']' token" on the bolded lines. The error occurs twice on the first bolded line and once on the second.
#include
using namespace std;
int FillArray(int List[]);
void GetMeanOfOdds(int TotalSumOddNumbers, int NumberOfOdds);
void GetMeanOfEvens(int TotalSumEvenNumbers, int NumberOfEvens);
int main()
{
int List[25];
List[] = FillArray(List[]);
int L, TotalSumOddNumbers=0, TotalSumEvenNumbers=0, NumberOfOdds=0, NumberOfEvens=0;
for(L=0; L<=25; L++)
{
if (List[L] % 2 == 0)
{
TotalSumEvenNumbers = List[L] + TotalSumEvenNumbers;
NumberOfEvens++;
}
if (List[L] % 2 != 0)
{
TotalSumOddNumbers = List[L] + TotalSumOddNumbers;
NumberOfOdds++;
}
}
if(NumberOfOdds > 0) //Decides whether or not to display information about the average of the odd numbers.
GetMeanOfOdds(TotalSumOddNumbers, NumberOfOdds);
if(NumberOfEvens > 0) //Decides whether or not to display information about the average of the even numbers.
GetMeanOfEvens(TotalSumEvenNumbers, NumberOfEvens);
}
int FillArray(int List[])
{
int K=0;
cout << "Enter -99 at any time to quit.\n";
for ( ; K<25 ; K++ )
{
cout << "Enter value for the index value of " << K << ".\n";
cin >> List[K];
if (List[K] == -99)
break;
}
return List[];
}
void GetMeanOfOdds(int TotalSumOddNumbers, int NumberOfOdds) //Calculates and displays average of odd numbers.
{
double MeanOfOdds;
MeanOfOdds = TotalSumOddNumbers / NumberOfOdds;
cout << "The average of the odd numbers is: " << MeanOfOdds << "\n";
}
void GetMeanOfEvens(int TotalSumEvenNumbers, int NumberOfEvens) //Calculalates and displays average of even numbers.
{
double MeanOfEvens;
MeanOfEvens = TotalSumEvenNumbers / NumberOfEvens;
cout << "The average of the even numbers is: " << MeanOfEvens << "\n";
}
Basically, I'm not sure where I'm supposed to put "List[]", "List", or "List[25]". I've tried different arrangements and only get more errors.
Thanks in advance!
This is for an intro C++ class. The assignment is to design and implement a program that will accept up to twenty-five integers. It must include the following functions:
* An input function that fills the array
* A function that finds and displays the average of the even numbers in the collection.
* A function that finds and displays the average of the odd numbers in the collection.
I keep getting this error: "error: expected primary-expression before ']' token" on the bolded lines. The error occurs twice on the first bolded line and once on the second.
#include
using namespace std;
int FillArray(int List[]);
void GetMeanOfOdds(int TotalSumOddNumbers, int NumberOfOdds);
void GetMeanOfEvens(int TotalSumEvenNumbers, int NumberOfEvens);
int main()
{
int List[25];
List[] = FillArray(List[]);
int L, TotalSumOddNumbers=0, TotalSumEvenNumbers=0, NumberOfOdds=0, NumberOfEvens=0;
for(L=0; L<=25; L++)
{
if (List[L] % 2 == 0)
{
TotalSumEvenNumbers = List[L] + TotalSumEvenNumbers;
NumberOfEvens++;
}
if (List[L] % 2 != 0)
{
TotalSumOddNumbers = List[L] + TotalSumOddNumbers;
NumberOfOdds++;
}
}
if(NumberOfOdds > 0) //Decides whether or not to display information about the average of the odd numbers.
GetMeanOfOdds(TotalSumOddNumbers, NumberOfOdds);
if(NumberOfEvens > 0) //Decides whether or not to display information about the average of the even numbers.
GetMeanOfEvens(TotalSumEvenNumbers, NumberOfEvens);
}
int FillArray(int List[])
{
int K=0;
cout << "Enter -99 at any time to quit.\n";
for ( ; K<25 ; K++ )
{
cout << "Enter value for the index value of " << K << ".\n";
cin >> List[K];
if (List[K] == -99)
break;
}
return List[];
}
void GetMeanOfOdds(int TotalSumOddNumbers, int NumberOfOdds) //Calculates and displays average of odd numbers.
{
double MeanOfOdds;
MeanOfOdds = TotalSumOddNumbers / NumberOfOdds;
cout << "The average of the odd numbers is: " << MeanOfOdds << "\n";
}
void GetMeanOfEvens(int TotalSumEvenNumbers, int NumberOfEvens) //Calculalates and displays average of even numbers.
{
double MeanOfEvens;
MeanOfEvens = TotalSumEvenNumbers / NumberOfEvens;
cout << "The average of the even numbers is: " << MeanOfEvens << "\n";
}
Basically, I'm not sure where I'm supposed to put "List[]", "List", or "List[25]". I've tried different arrangements and only get more errors.
Thanks in advance!
