+ 2
What's the output? Why is 10 and 0?
include <stdio.h> int main() { int var1, var2; var1=10; var2=10; var2= 2*(++var1)-2*(--var1); printf(" Var1= %d \n Var2= %d",var1,var2); return 0; }
2 ответов
+ 3
Gabbro Your syntax is wrong and every answer that tries to explain why the output is 10 and 0 is wrong as well. Changing the value of a variable more than once in the same expression will lead to undefined behavior. The values might be 10 and 0 with your compiler and on your platform and they might be totally different under other circumstances. It's not defined what happens when you use an expression like the one in your question
+ 1
Var1 =10
Var2 = 0
For priority observance