From what I see, your main problem is that you haven't understood how to initialize your static variables.
It's very simple.
The trick is to understand that since the variables are static, they are supposed to keep their values between function calls. Therefore they cannot and will not be reset to their initialization values (otherwise they'd be useless).
In fact, the initialization values will be used only the first time the function is called.
Every subsequent call of the function will behave as if the initialization code was not there.
Since you want to use your static variables as accumulators, their starting value should be 0. The code to initialize them is:
1 2
|
static float iTotal = 0;
static int iNumQ = 0;
|
And nothing else !
Now, all you have to do is to write the code to accumulate the values.
It's pretty simple: when the function is called, add iGrade to iTotal and add 1 to iNumQ.
I think you can do it by yourself.