+ 1
Why x and y occur twice
#include <stdio.h> int sum_up (int x, int y); int main() { int x, y, result; x = 3; y = 12; result = sum_up(x, y); printf("%d + %d = %d", x, y, result); return 0; } int sum_up (int x, int y) { x += y; return(x); } Why x and y occur twice? I mean one before main() an the other after it. how do we know which one is being called? thank you in advance ^^
2 Respostas
+ 4
In wich and every function, you need to define variables explicitly , therefore in main ()
x and y is defined for 1st time and. In function. sum_up() it is defined for 2nd time...
+ 4
These variables defined under any specific function are called local variables and to avoid this situation you can have Global variables..........