0
I am confused with the output.
4 Respostas
+ 3
int x=3,y,z;
Here you intilize x =3 after that
y=x=10;
Here x and y both are 10
z=x<10;
Here you used conditional operator this will give bool value here z=x<10 (10<10) this condition is false so 0 will assign to z variable after that printf will print values x and y were 10 but z is 0 so final Output is 10 10 0
printf ("x=%d y=%d z=%d",x,y,z);
+ 1
The variable a inside main is local variable.It is visible only inside the main function.It is firstly declared and not initialized so default value of a is 0 .Then it is assgned 20 so then the outputs 0 and 20.The a outside the main is global variable .
+ 1
The program demonstrates the concept of scope. Line 2 declares a global variable "a" and assigns an initial value of 10. Line 4 within main() declares a local variable also named "a" and does not give it an initial value. When main() refers to variable "a" in the printf() statement, the compiler uses the local variable. The local "a" is uninitialized, so it prints an unpredictable value. When main() assigns a value and prints the new value, again it is using only the local variable. The global "a" is a different variable and never gets used in this program.
EDIT: You have changed the program link, so now this answer, and those before, no longer apply.
0
Check some Youtube videos about variable scope in C.
Good luck 😃