That is because you are putting the code for the function inside the main function. You need to move that code outside of the main function. Try this instead:
Code:
#include <iostream.h>
void top_score(char [][8],char [][8], int [][3], int, int);
void main(void)
{
const int exam = 3;
const int student= 4;
char last_name[student][8];
char first_name[student][8];
int scores[student][exam];
int j=0,top,counter=0;
float average=0;
for(int i=0; i<student; i++)
{
cout<<"Enter first name for student "<<i+1<<": ";
cin>>first_name[i];
cout<<"Enter last name for student "<<i+1<<": ";
cin>>last_name[i];
}
for(i=0;i<student; i++)
{
for( j=0;j<exam; j++)
{
cout<<"Enter score #"<<j+1<<"for "<<first_name[i]
<< " " <<last_name[i]<<": ";
cin>>scores[i][j];
}
top_score(first_name, last_name, scores, student, exam);
}
for(i=0;i<student;i++)
{
for(j=0;j<exam;j++)
{
average=average+scores[i][j];
counter++;
}
}
cout<<"\n"<<"The Total Class: Average " << average/counter << endl;
}
void top_score(char first[][8],char last[][8],int grades[][exam],int students,int exams)
{
cout<<endl;
top=grades[0][0];
for(i=0;i<students;i++)
{
for(j=0;j<exams;j++)
{
if(grades[i][j]>top) top=grades[i][j];
}
cout<<"Student First Name: "<<first_name[i]<<" Student Last Name: "
<<last_name[i]<<" Top Exam Score: "<<top<<"\n";
top=0;
}
}
There may be other errors, but this should address the error you mentioned.