5 Replies - 4086 Views - Last Post: 18 May 2009 - 11:36 PM Rate Topic: -----

#1 IdonnoY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 15-May 09

term does not evaluate to a function taking 3 arguments

Post icon  Posted 18 May 2009 - 11:04 PM

here's a piece of my program.... i've written a function that is suppose to add test scores in an array for quiz 1, then i call it again to do it again for quiz 2 up to six quizes but every time i do it... i get this error...


declared it in my prototypes:

double avg(studRecord x[], int& cnt, int j);

called it in my main:

quiz1Avg = avg(student, cnt, 0);
defined it:

double avg (studRecord x[], int& cnt, int j)
{
	double total = 0;
	double avg = 0;

	for (int i=1; i <= cnt; i++)
	{
		total += x[i].quiz[j];
	}
	avg = total/cnt;

	return avg;
}


when i build my program i get an error message that says "term does not evaluate to a function taking 3 arguments"
What does that mean?

any suggestions?? :blink:

Is This A Good Question/Topic? 0
  • +

Replies To: term does not evaluate to a function taking 3 arguments

#2 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: term does not evaluate to a function taking 3 arguments

Posted 18 May 2009 - 11:11 PM

Could you please post the rest of your code?

This post has been edited by apw5020: 18 May 2009 - 11:12 PM

Was This Post Helpful? 0
  • +
  • -

#3 IdonnoY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 15-May 09

Re: term does not evaluate to a function taking 3 arguments

Posted 18 May 2009 - 11:14 PM

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cmath>

using namespace std;

struct studRecord
{
	string ID, lastName, firstName;
	int quiz[6];
	int midterm, final;
	double avg;
	char grade;
};

//Function prototypes
void readFile(studRecord [], int&);
void bubbleSort(studRecord[], int n);
int findMax(studRecord[], int size);
int findMin(studRecord[], int size);
void findAvg(studRecord x[], int& cnt, int& midterm, int& final);
void writeFile(studRecord [], int);
double avg(studRecord x[], int& cnt, int j);
double mAvg (studRecord x[], int& cnt);
double fAvg (studRecord x[], int& cnt);
double avgAvg (studRecord x[], int& cnt);
double mdev(studRecord x[], int& cnt, double& midAvg);
double fdev(studRecord x[], int& cnt, double& finalAvg);
double adev(studRecord x[], int& cnt, double& TavgAvg);
double mmax(studRecord x[], int& cnt);
double mmin(studRecord x[], int& cnt);
double fmax(studRecord x[], int& cnt);
double fmin(studRecord x[], int& cnt);
double amax(studRecord x[], int& cnt);
double amin(studRecord x[], int& cnt);




 
void main ()
{
	studRecord student[100];
	int cnt,midterm, final;
	double avg = 0.0;
	double quiz1Avg = 0.0;
	double midAvg = 0.0;
	double finalAvg = 0.0;
	double TavgAvg = 0.0;
	double stDev = 0.0;
	double midDev = 0.0;
	double finalDev = 0.0;
	double midMax = 0;
	double midMin = 0;
	double finalMax = 0;
	double finalMin = 0;
	double avgMax = 0;
	double avgMin = 0;
	
	
	readFile (student, cnt);
	if (cnt > 0)
	{
	
		bubbleSort(student, cnt);		// sorts by last name
		findAvg(student, cnt, midterm, final);	// finds avg of each student
		writeFile(student, cnt);
		quiz1Avg = avg(student, cnt, 0);
		midAvg = mAvg(student, cnt);	// avg of midterm exam
		finalAvg = fAvg(student, cnt);  // avg of final exam
		TavgAvg = avgAvg(student, cnt); //total avg of averages
		midDev = mdev(student, cnt, midAvg);		// finds the standard deviation of the averages
		finalDev = fdev(student, cnt, finalAvg);		// finds the standard deviation of the finals
		stDev = adev(student, cnt, TavgAvg);		// finds the standard deviation of the averages
		midMax = mmax(student, cnt);	// finds the highest midterm score
		midMin = mmin(student, cnt);	// finds the lowest midterm score
		finalMax = fmax(student, cnt);	// finds the highest final score
		finalMin = fmin(student, cnt);	// finds the lowest final score
		avgMax = amax(student, cnt);	// finds the highest average score
		avgMin = amin(student, cnt);	// finds the lowest average score
		
	}
	else
		cout << "File not found!" << endl;
	cout << endl;
}



that's without all the function definitions....
Was This Post Helpful? 0
  • +
  • -

#5 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: term does not evaluate to a function taking 3 arguments

Posted 18 May 2009 - 11:27 PM

Ah I see. You have a variable named avg which has the same name as your function avg. Try changing the name of one of them and let me know what happens.

This post has been edited by apw5020: 18 May 2009 - 11:27 PM

Was This Post Helpful? 1
  • +
  • -

#6 IdonnoY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 15-May 09

Re: term does not evaluate to a function taking 3 arguments

Posted 18 May 2009 - 11:31 PM

looks like that did it!!!!!
Thanks!!!
Was This Post Helpful? 0
  • +
  • -

#7 apw5020  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 666
  • Joined: 26-March 09

Re: term does not evaluate to a function taking 3 arguments

Posted 18 May 2009 - 11:36 PM

Good, always glad to help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1