Well my class just learned functions but i don't seem to be quite getting it. So naturally trying to do my homework assignment i feel lost. I did make some good progress but i can't seem to get past this error. I don't know what it wants me to do.

error C2660: 'findLow' : function does not take 0 arguments
error C2660: 'calcAvg' : function does not take 0 arguments

The assignment is to create a program where the program asks for 5 test scores, finds the lowest and calculates the average of the other 4. All of this must be done in the functions, void getValues(); void calcAvg (int, int, int, int, int); and int findLow (int, int, int, int, int);

Finally here is my code. I hope you guys can help because im so lost and i have 4 function assignments due by next week :(

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

using namespace std;

void getValues ();
int findLow (int s1, int s2, int s3, int s4, int s5);
void calcAvg (int s1, int s2, int s3, int s4, int s5);


void getValues ()
{
	cout << "Enter five test scores: \n";
	cout << "\t ";
	int s1, s2, s3, s4, s5;
	cin >> s1 >> s2 >> s3 >> s4 >> s5;
}

int findLow (int s1, int s2, int s3, int s4, int s5)
{
	int lowest = s1;
	{
		if (s2 < lowest) 
			lowest = s2;
		if (s3 < lowest) 
			lowest = s3;
		if (s4 < lowest) 
			lowest = s4;
		if (s5 < lowest) 
			lowest = s5;
		cout << "lowest score is: " << lowest << endl;

		return lowest;
	}
}

void calcAvg (int s1, int s2, int s3, int s4, int s5)
{

	float tot_4, avg;
	{
		tot_4 = (s1+s2+s3+s4+s5) - findLow();
		avg = tot_4 / 4;
		cout << "The average of four highest scores is: " << avg;
		cout << endl;
	}
}

int main()
{

	getValues ();
	findLow ();
	calcAvg ();

	return 0;
}

>I don't know what it wants me to do.
>error C2660: 'findLow' : function does not take 0 arguments
>error C2660: 'calcAvg' : function does not take 0 arguments
Maybe, just maybe, it wants you to pass arguments to findLow and calcAvg? The big problem is that getValues doesn't have any way of sending the input back to main so that you can pass it on to findLow and calcAvg. You need to redesign that particular function.

Doesn't that mean i would have to change the void getValues() to int getValues()?

>Doesn't that mean i would have to change the void getValues() to int getValues()?
Only if you change getValues so that it only returns one test score at a time.

One of the things functions can do is call other functions. You've already demostrated that by calling getValues(), findLow(), etc from within the function called main(). If you aren't able to change the function prototype/definition, then this fact should be able to help you devise a flow to the program to do what you want.

Then, if the prototype/definition indicates arguments/parameters are to be sent to the funtion when calling the function, then you shuold send them, in the order and of the type specified in the prototype/definition.

This article has been dead for over six months. Start a new discussion instead.