0
Why does this code prints 20 instead of 30?
#include <stdio.h> void fun (int x){ x = 30; } int main(){ int y = 20; fun(y); printf("%d", y); return 0; }
2 odpowiedzi
+ 4
You are passing the value of *y* to the function instead of variable *y* itself, this means when inside function, no matter whatever you do with *x*, no changes will be reflected back to *y* thus the output 20.