I've tried Googling and actually searching this website for a concise answer on this and so far I have been unable to find some help, I believe it might be because the answer is too simple.
I have just started uni and we have some exercises to resolve. In one of them I am presented with the following:
float avge(int a, int b, int c) {
float res;
res = (a + b + c) / 3.0;
return res;
}
int main() {
int n1, n2, n3;
float m;
cin >> n1;
cin >> n2;
cin >> n3;
m = avge(n1, n2, n3);
cout << m << endl;
return 0;
}
It works as intended but I can't understand what res
does for the code. Could someone explain it to me?