Help!! I dont know whats wrong

This is my current code:

//inlcude directories
#include <iostream>
#include <fstream>

//declare standard
using namespace std;

//declare function to print menu
void PrintMenu();

//declare function to print student analyzing menu
void analyzeStudentMenu();

//declare function to find minimum grade
float FindMinimum(float, int);

//main function
int main ()
{
//declare constants for number of students and grades
const int MAX_STUDENTS=20;
const int MAX_TESTS=5;

//declare 2D array with the student and grade constants
float gradeArray [MAX_STUDENTS][MAX_TESTS];

//declare array to store student names
string nameArray [MAX_STUDENTS];

//declare filestream
string scoreFile;
ifstream FileName;

//declare integer for number of grades per student
int numGrades;

//declare count integer to store names and grades in arrays
int count=0;

//declare variable for input
int option;

//declare variable for option 1 input
int choice;

//declare variable for student number
int nameNumber;

//declare variable for minimum grade
float minimum;

//ask for file and input file name
cout<<"Please enter the file to be processed: "<<endl;
cin>>scoreFile;

//open file
FileName.open(scoreFile.c_str());

//if file does not exist, output that it is invalid and terminate program
if(!FileName)
{
cout<<"Invalid File"<<endl;
cout<<"Program Terminated"<<endl;
return -1;
}

//get the number of grades that each student has
FileName>>numGrades;

//continue with while loop until end of file
while(FileName)
{

//get next data in file as the next variable in the student name array
FileName>>nameArray[count];

//for loop to process the grades for one student
for(int j=0; j<numGrades; j++)
{
//store the next grade of the student into the next variable of the grades array
FileName>>gradeArray[count][j];
}

//update the count integer to get next student
count++;

}

//for loop to print out the student names
for(int i=0; i<count-1; i++)
{
//print out next student name
cout<<nameArray[i]<<" ";

//for loop to print out each students grades
for(int k=0; k<numGrades; k++)
{
//print out the next grade of the student
cout<<gradeArray[i][k]<<" ";
}
//add an end of line between students
cout<<endl;
}

//call function to print menu
PrintMenu();

//get input
cin>>option;
cout<<endl;

//if user picks option 1
while(option==1)
{
//print menu for option 1
analyzeStudentMenu();
//get users choice
cin>>choice;
cout<<endl;

//if user wants to find the min
if(choice==1)
{
cout<<"Please select a student number:"<<endl;

//declare counter integer to print names
for(int counter=0; counter<count-1; counter++)
{
cout<<counter<<". "<<nameArray[counter]<<endl;
}
cin>>nameNumber;
cout<<endl;

minimum=FindMinimum(gradeArray[count][numGrades], choice);
cout<<nameArray[choice]<<"'s lowest score is: "<<minimum<<endl;
}
}

return 0;
}
//definition of PrintMenu
void PrintMenu()
{
//ask for a choice and print out the menu options
cout<<"Please select from one of the following options:"<<endl;
cout<<"1. Operate on a student"<<endl;
cout<<"2. Print out students and exam scores"<<endl;
cout<<"3. Quit"<<endl;
}
//definition of analyzeStudentMenu
void analyzeStudentMenu()
{
cout<<"Please make a choice:"<<endl;
cout<<"1. Find the Min"<<endl;
cout<<"2. Find the Max"<<endl;
cout<<"3. Find the Average"<<endl;
}
//definition of function to find minimum grade
float FindMinimum(float gradeArray[][numGrades], int choice)
{
//declare variable for minimum value
float minValue;

//set first grade to minimum value
gradeArray[choice][0]=minValue;

//loop to find minimum value
for(int c=1; c<numGrades; c++)
{
if (gradeArray[choice][c]<minValue)
{
minValue=gradeArray[choice][c];
}
}
return minValue;
}

This is my current error messages:
ola9.cc:159: error: 'numGrades' was not declared in this scope
ola9.cc:159: error: expected ')' before ',' token
ola9.cc:159: error: expected unqualified-id before 'int'

I cannot figure out what is wrong for the life of me. Can anyone help me understand?

This is the line it is referring to:
float FindMinimum(float gradeArray[][numGrades], int choice)
Hi rachelbair,

Well its best when you do big programs like this to take it one step at a time. There are lots and lots of errors and your code is very hard to follow along with. Can you post your code in between the code and /code so we can see what line 159 is.

The errors are these three:
ola9.cc:159: error: 'numGrades' was not declared in this scope
ola9.cc:159: error: expected ')' before ',' token
ola9.cc:159: error: expected unqualified-id before 'int'

Line 159 is:
float FindMinimum(float gradeArray[][numGrades], int choice)
This is what I am trying to do:

float FindMinimum(float gradeArray[][numGrades], int choice)
{
//declare variable for minimum value
float minValue;

//set first grade to minimum value
gradeArray[choice][0]=minValue;

//loop to find minimum value
for(int c=1; c<numGrades; c++)
{
if (gradeArray[choice][c]<minValue)
{
minValue=gradeArray[choice][c];
}
}
return minValue;
}

This is the function call:

minimum=FindMinimum(gradeArray[count][numGrades], choice);

And the function declaration:

float FindMinimum(float, int);
And also, part of the assignment is to declare the arrays like this:

const int MAX_STUDENTS=20;
const int MAX_TESTS=5;


float gradeArray [MAX_STUDENTS][MAX_TESTS];


string nameArray [MAX_STUDENTS];
I understand what line 159 is however it is difficult for me to see what is going on with the way it is formatted. it seems to me just looking at it the prototype and the actual function call differ. "numGrades was not declared in this scope" means that the function doesn't know what the variable 'numGrades' means. You have to pass the the variables you need to use to the function. Functions don't know whats in main unless you tell them. I am unsure what numGrades mean. Is that how many students you have? If you post the code in between the (code) *code goes here* (/code) it will help both of us.
"(code) *code goes here* (/code)"--im sorry, im still a beginner, what does this mean? how do I post my code that way?

how can I pass a 2D array into a function without giving the columns an actual number?

int 2DArray[][thisNumberCanChange];

what would I put in the column bracket?

numGrades is how many grades are available for each student. In the file that I am pulling into the program, there are 3 grades per student, therefore the number 3 is stored into the variable numGrades
Topic archived. No new replies allowed.