My function is supposed to return a local variable. It manages to do this without any compiler issues even though variable is out of scope.
int add(int a, int b);
{
int result=0;
result = a + b;
return (result); // result scope should be limited to this method
}
int main()
{
int res=0;
res = (3 + 4);
printf("Result : %d \n", res);
return 0;
}
Can anyone please explain this behavior.