I just got a quiz back and I have to listen to the teacher lecture about "functions" because I supposedly missed one. I got a 14/15 because of this question...
3)Write a function that returns the sum of three floats
float random_function(float var1, float var2, float var3) {
return var1+var2+var3;
}
4) Assume that any necessary variables have been declared. Write a function call for the created function in number 3.
random_function(var1, var2, var3);
I got minus 1 for number 4. She put an R = before the function. Now she didn't ask to store the variable that it returns. Sure, you'd have to, but that is NOT part of the function call.
So now, no Dance Dance Revolution during C class because of that. (Well, I'm sneaking and typing this right now, so you'd better believe I'll sneak and do that as well |): )
I got minus 1 for number 4. She put an R = before the function. Now she didn't ask to store the variable that it returns. Sure, you'd have to, but that is NOT part of the function call.
To my knowledge, you are correct. And, you don't have to store it in anything. The below is valid C++ code.