# Thread: Having a little trouble with my first array

1. ## Having a little trouble with my first array

This program was working fine until i added the highest score function
something about local function definitions are illegal???

As always help is greatly appreciated thanks for any many times over!!

Code:
```#include <iostream>

using namespace std;

//**********************************************Function prototypes
void enterScore(int score[]);
void averageScore(int score[]);
void highestScore(int score[]);

//**********************************************Function main
void main()
{
int score[5];

enterScore(score);
averageScore(score);
highestScore(score);

}

//*************************enter score function********************************************

{
for (int x = 0; x<5; x++)
{
cout << "\nEnter score #"<<" ";

}
}

//**************************average score function*******************************************
void averageScore(int num[])
{
int tot = 0;
int avg = 0;

for (int x=0; x<5; x++)

tot+=num[x];

avg = tot/5;

cout <<"\n" << tot <<" is the total of the test scores. "<<"\n";
cout <<"\n" << avg <<" is the average test score. "<<"\n";

//***************************highest score function******************************************

void highestScore (int exam[])
{								//local function definitions are illegal???

for (int x=0; x<5; x++)

{

if (exam[x] > highestScore)

highestScore = exam[x];

}

}

cout <<"\n" << highestScore <<" is the highest test scores. "<<"\n";

return;

}```

2. Hi dAzed,

You missed the closing curly bracket } at the end of void averageScore(int num[]) - it thinks you're trying to declare void highestScore (int exam[]) in void averageScore(int num[]).

3. cout <<"\n" << tot <<" is the total of the test scores. "<<"\n";
cout <<"\n" << avg <<" is the average test score. "<<"\n";
there´s a } sign missing, also, in the last funcyion I believe you close a bracket } you never opened

4. >>void main()

int main()

Good!

5. I correct some little error, now it's pass compiling:

Code:
```    #include <iostream>
using namespace std;

//**********************************************Func  tion prototypes
void enterScore(int score&#091;&#093;);
void averageScore(int score&#091;&#093;);
void highestScore(int score&#091;&#093;);

//**********************************************Func  tion main
int main()
{
int score&#091;5&#093;;
enterScore(score);
averageScore(score);
highestScore(score);

system("pause");
return 0;
}

//*************************enter score function******************************************  **

{
for (int x = 0; x<5; x++)
{
cout << "\nEnter score #"<<" ";

}
}

//**************************average score function******************************************  *
void averageScore(int num&#091;&#093;)
{
int tot = 0;
int avg = 0;

for (int x=0; x<5; x++)

tot+=num&#091;x&#093;;

avg = tot/5;

cout <<"\n" << tot <<" is the total of the test scores. "<<"\n";
cout <<"\n" << avg <<" is the average test score. "<<"\n";

//***************************highest score function******************************************

void highestScore (int exam&#091;&#093;)
{
int highestScore = 0;
//local function definitions are illegal???
for (int x=0; x<5; x++)
{   if (exam&#091;x&#093; > highestScore)
highestScore = exam&#091;x&#093;;
}
cout << "\n" << highestScore
<< " is the highest test scores. " << "\n";

return;
}```