Trouble with errors

This is a discussion on Trouble with errors within the C# Programming forums, part of the General Programming Boards category; I keep coming up with 2 errors with my code. These are the errors ||In function 'double arrayLabAve(int, double*)':| |188|error: ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    3

    Trouble with errors

    I keep coming up with 2 errors with my code. These are the errors

    ||In function 'double arrayLabAve(int, double*)':|
    |188|error: a function-definition is not allowed here before '{' token|
    |214|error: expected '}' at end of input|
    ||=== Build finished: 2 errors, 0 warnings ===|

    Here is my
    Code:
    #include <iostream>
    
    using namespace std;
    	#define Max_Students 10
    
            int grades;
            int eScores;
            int lScores;
    		int getStudentCount();
    		int getExamScores(int,float*);
    		int getLabScores(int,float*);
    		void calculatePointGrades(float[],int,float[]);
    		void calculateLetterGrades(int,float[]);
    		float ExamGrade[Max_Students];
    		float LabGrade[Max_Students];
    		float PointGrade[Max_Students];
    		char LetterGrade[Max_Students];
    		void showGradeData(double[],double[],char[], double[],int);
    		double arrayExamAve(int, double[]);
    		double arrayLabAve(int, double[]);
    		void arrayLetterGrades(int, double[]);
    		void arrayPointGrades (int, double[]);
    // Declare functions here, include the necessary parameters here and in the actual functions below.
    // (once the function prototypes are created, the main()
    // function can be moved back to the top of the code.)
    
    // Declare the arrays here
    
    
    
    void display(int);
    
    int main()
    {
    		int NumStudents;
    			NumStudents = getStudentCount();
    			getExamScores(NumStudents, ExamGrade);
    			getLabScores(NumStudents, LabGrade);
    			calculatePointGrades(ExamGrade,NumStudents,LabGrade);
    			calculateLetterGrades(NumStudents,PointGrade);
    			display(NumStudents);
      cin.ignore(2);
    }
    
    int getStudentCount()
    // functions that gets total number of students
    {
    		int StudentInput;
    			cout << "Enter the number of students: ";
    			cin>>StudentInput;
    
    			cout<<endl;
    
    return StudentInput;
    }
    
    int getExamScores (int count , float *Grade)
    // function that gets Exam Grade
    {
    			cout<<endl;
    
        for (int student = 0; student <count; ++student)
    	{
    			cout << "enter exam grade for student "<< student+1 <<": ";
    			cin >> *Grade;
    					Grade++;
    	}
    
    			cout<<endl;
    return 0;
    }
    
    
    int getLabScores (int count , float *Grade)
    // function that get Lab Average grade
    {
    			cout<<endl;
        for (int student = 0; student <count; ++student)
    	{
    			cout << "enter lab grade for student "<< student+1 <<": ";
    			cin >> *Grade;
    					Grade++;
    	}
        cout<<endl;
    
    
    return 0;
     }
    
    
    void calculatePointGrades(float LabGrade[],int count, float ExamGrade[])
    // function that calculates Point Grade by getting ExamGrade and LabAverage as arguments
      {
    	for (int student = 0; student < count; student++)
    	  {
    	       PointGrade[student] = (.7*ExamGrade[student]) + (.3*LabGrade[student]);
    	  }
      }
    
    void calculateLetterGrades(int count,float PointGrade[])
    // function that calculates Letter Grades based on Point Grade
      {
    	for (int student = 0; student < count; ++student)
    	  {
    	      if(PointGrade[student]>=90)
    		 LetterGrade[student]='A';
    	      else if(PointGrade[student]>=80 && PointGrade[student]<90)
    		 LetterGrade[student]='B';
    	      else if(PointGrade[student]>=70 && PointGrade[student]<80)
    		 LetterGrade[student]='C';
    	      else if(PointGrade[student]>=60 && PointGrade[student]<70)
    		 LetterGrade[student]='D';
    	      else
    		 LetterGrade[student]='F';
    
    	  }
      }
    void showGradeData(double arrayExamAve[],double arrayLabAve[],char arrayLetterGrades[], double arrayPointGrades[],int getStudentCount )
    // Prints a table of the student's scores and grades from the arrays
    {
    			cout << arrayExamAve[eScores] << arrayLabAve[lScores] << arrayLetterGrades[grades] << arrayPointGrades[grades];
    			cout <<endl;
    // this statement is used for intial test and debugging
    // returns no values to main
    }
    
    
    double arrayExamAve(int numStudents,double arrayExamAve[])
    // Averages the student's numeric exam grades from the array
    {
    		int eScores=0;
    		int sum=0;
    		int ave=0;
    	for (sum = 0; sum <= numStudents; sum++)
    {			sum = sum + arrayExamAve[eScores];
    			ave = sum/numStudents;
    }
    // this statement is used for intial test and debugging
    
    return ave;
    // returns average exam score to main
    }
    
    
    double arrayLabAve(int numStudents,double arrayLabAve[])
    // Averages the student's numeric lab grades from the array
    {
    int lScores=0;
    int sum=0;
    int aveg=0;
    for (sum = 0; sum <= numStudents; sum++)
    { sum = sum + arrayLabAve[lScores];
    aveg = sum/numStudents;
    }
    
    
    void display(int count)
    // function that display the mark details along with total average
    {
         int TotalExamGrade=0;
          float TotalLabGrade=0.0,TotalPointScore=0.0;
    	  // variables for finding total
    
          float AvgExamGrade,AvgLabGrade,AvgPointScore;
          // variables for finding average
    
    
    			cout<<"\n\nSNO"<<"\t"<<"EXAM SCORE"<<"\t"<<"LAB SCORE"<<"\t\t"<<"POINT GRADE"<<"\t"<<"LETTER GRADE"<<endl;
        for(int student=0; student<count ; student++)
    	{
    			cout<<student+1<<"\t"<<ExamGrade[student]<<"\t\t"<<LabGrade[student]<<"\t\t"<<PointGrade[student]<<"\t\t"<<LetterGrade[student]<<endl;
    
    	    TotalExamGrade = TotalExamGrade + ExamGrade[student];
    	    TotalLabGrade = TotalLabGrade + LabGrade[student];
    	    TotalPointScore = TotalPointScore + PointGrade[student];
    	}
    
          AvgExamGrade = (float)TotalExamGrade / count;
          AvgLabGrade = TotalLabGrade / count;
          AvgPointScore = TotalPointScore / count;
    
    			cout<<"\n\n Exam Average        : "<<AvgExamGrade;
    			cout<<"\n Lab Average Average : "<<AvgLabGrade;
    			cout<<"\n Point Score Average : "<<AvgPointScore;
      }
    Any help would be great.
    Thanks

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You never close your LabAve function before starting the next one.

    (And is this really C#? Doesn't look it.)

  3. #3
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    This is not C#, its C++. And, I think "Code readability 101" needs to be the first required class in every computer science program. Like tabstop said, your arrayLabAve function is left with no return command and no closing brace.
    The keyboard is the standard device used to cause computer errors!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 04:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 11:50 AM
  3. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 01:28 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21