hi,
Can anyone explain me the results of the following program....
insertAccording to my understandingCode:main() { int i=-3,j=2,k=0,m; m=++i && ++j || ++k; printf("%d %d %d %d",i.j,k,m); }
&& operation will be the first one to execute....when compared to || so....
++i will be -2
and
++j will be 3
since ++i and ++j are used in an expressin (&&) these two values will be incremented first and then logical && operator will be applied...Please correct me if i am wrong.
so the result will be 0
this 0 is logically OR'ed with ++k;
++k will be 1 now.(since it is used in expression)
so
0 || 1 will result in 1
so the output must be....
-2,3,1,1....but when i type the program and execute in GCC
its giving the output
-2,3,0,1
I didn't understand why k is not getting incremented....
Please give me some explanation or correct me if i am wrong.....
Regards,
Ram



LinkBack URL
About LinkBacks



