views:

26

answers:

2

error C2065: 'exam1' : undeclared identifier

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
void read_file_in_array(int exam[100][3]);
double calculate_total(int exam1[], int exam2[], int exam3[]); // function that calcualates grades to see how many 90,80,70,60
//void display_totals();

int main()
{
    int go,go2,go3;
    go=read_file_in_array(exam);
    go2=calculate_total(exam1,exam2,exam3);
    //go3=display_totals();
    cout << go,go2,go3;
    return 0;
}/*
int display_totals()
{

    int grade_total;
    grade_total=calculate_total(exam1,exam2,exam3);
    return 0;
}   */
double calculate_total(int exam1[],int exam2[],int exam3[])
{
    int calc_tot,above90=0, above80=0, above70=0, above60=0,i,j;
    calc_tot=read_file_in_array(exam);
    for(i=0;i<100;i++)
        {
            exam1[i]=exam[100][0];
            exam2[i]=exam[100][1];
            exam3[i]=exam[100][2];
            if(exam1[i] <=90 && exam1[i] >=100)
                {
                    above90++;
                    cout << above90;
                }
        }
        return exam3[i];

}

void read_file_in_array(double exam[100][3])
{
  ifstream infile;  

  int num, i=0,j=0;
  infile.open("grades.txt");// file containing numbers in 3 columns
    if(infile.fail()) // checks to see if file opended
    {
        cout << "error" << endl;
    }
  while(!infile.eof()) // reads file to end of line
      {
          for(i=0;i<100;i++) // array numbers less than 100
          {
            for(j=0;j<3;j++) // while reading get 1st array or element
            infile >> exam[i][j];
            infile >> exam[i][j];
            infile >> exam[i][j];
            cout << exam[i][j] << endl;
          }
          exam[i][j]=exam1[i];
          exam[i][j]=exam2[i];
          exam[i][j]=exam3[i];

      }
  infile.close();

}
+1  A: 
go=read_file_in_array(exam);

exam is not declared in the scope of main :-? How about declaring it (perhaps int exam[100][3])

nc3b
+1  A: 

Apparently You did not declare the "exam", "exam1", "exam2" and "exam3" identifiers.

This line:

void read_file_in_array(int exam[100][3]);

declares read_file_in_array identifier but not exam.

You have to tell Your compiler what exam is and not only that. Declaring it might make Your file to compile, but it's not enough for a program to work. You have to actually define it. Definition is also a declaration, so defining it will do the trick. exam is used in the scope of main so I think You can define exam as a local variable in main. Try this

int main()
{
    int go,go2,go3;
    int exam[100][3];
    int exam1[100];
    int exam2[100];
    int exam3[100];
    go=read_file_in_array(exam);
    go2=calculate_total(exam1,exam2,exam3);
    //go3=display_totals();
    cout << go,go2,go3;
    return 0;
}/*
Maciej Hehl