Hi everyone...
I am working on a function that calculates several diff parts of student grades (Student is my stuct and has 6 parts of each students info IE: name, grades) I am trying to calculated the AVERAGe of those grades, transform them into a letter grade and return both & a status of 'passed' or 'failed'...my prob is with the code below...i think it is in my call for the Calcav and / or CalGrade.
I am getting an access violation and the exe crashes on this.
also i am not returning the average or grade from other functions that work on their own -assuming that the prototypes are correct
can anyone see a problem with the highlighted lines or anywhere else???? thanks a bunch all, this forum has taught me more than my class has!!
Mouse
[code]
//Function Calculate=====================
void Calculate(Student CL[], int ns){
for ( int x =0; x,ns; x++){
CL[x].average = Calcav(CL[x].exams, 4);
CL[x].letgrade = CalcGrade(CL[x].average);
//CL[x].passed = status(CL[x].letgrade);
}
cout << CL[x].average << endl;
cout << CL[x].letgrade << endl;
}
//Function Calcave=====================
double Calcav(double ex[], int nex){
double Sum = 0;
double AV = 0;
nex = 4;
for (int x = 0; x < nex; x++){
Sum+= ex[x];
AV = Sum/nex;
}
return AV;
}
//Function CalcGrade=====================
char CalcGrade(double AV){
{
if(AV >= 90) return 'A';
if(AV >= 80) return 'B';
if(AV >= 70) return 'C';
if(AV >= 60) return 'D';
return 'F';
}
}