You stated the existence of a function qualityPoints:
int qualityPoints ( int );
which promises that if you give it an int, it will do something, and return an int to the caller. You even use it in this intended way in main:
cout<<"The student’s average is: "<<qualityPoints(x);
However, the function itself is a different qualityPoints that takes no parameters and returns an int:
int qualityPoints ( )
{
//code
}
C++ allows for multiple functions by the same name as long as the parameters are different. So you’re saying the first qualityPoints exists, and try to use it, but you’re defining a different one. When the compiler tries to tie all this together at link time, main ends up trying to call a qualityPoints that doesn’t exist.
Presumably you meant:
int qualityPoints ( int )
{
//code
}
…but even this isn’t enough to fix your problem. You haven’t given the incoming parameter any sort of name. Although you’re not required to in a function prototype as you have above main:
int qualityPoints ( int );
you are expected to give the variable a name in qualityPoints when you actually define the function later on:
int qualityPoints ( int x )
{
//code
}
Note that this x has nothing to do with the x in main whatsoever, except for the specific call to qualityPoints wherein a copy of main’s x is made so that qualityPoints’s x has a value. Main’s x could be changed to q throughout main, and it would have no impact on the current behaviour of the program, even if you just made the recommeded fixes to qualityPoints. Passed parameters in C++ are copied from the variables you specify at the time of call into the temporary corresponding local parameter values inside the called functions.
And neither of these has anything to do with the global variable int x that you have just before the definition of main. The int x inside main hides the one outside of main so you are never changing the global variable. Presumably somewhere in your real code you’re reading a value into x. You have to be absolutely sure which x you’re reading into.
If you intend to pass parameters via the function parameter list, that’s fine. If you intend to pass parameters by stuffing them in global variables that’s fine. Just don’t mix the two and get horribly confused.
My recommendation, since I detest global variables: Get rid of the int x; above main. Give the integer parameter to qualityPoints a name even in the prototype above main, but also make sure the parameter list matches in the definition of qualityPoints after main.