I am a newborn programmer and i've been studying trace tables thus far. However, it seems i'm unable to understand this one. By what i could gather the function would return (-15) as the variable 'a' receives 25 and later the 'num', which is 10, is subtracted by the former.
Yet it seems i'm wrong by PythonTutor's calculations and i still cannot get why num is still 10 after all that C magic. Would someone be so kind to explain why is this happening?
#include <stdio.h>
int num;
int func(int a, int b);
int main() {
int first = 0, sec = 50, num2;
num = 10;
num += func(first, sec);
printf("\nnum = %d\tfirst = %d\tsec = %d", num, first, sec);
return 0;
}
int func(int a, int b) {
a = (a + b) / 2;
num -= a;
return a;
}