# Answer to Question #25223 in C# for shivam gupta

Question #25223
tell me the logic of this(it is a program of c) main() {int x,y,z; x=y=z=-1; z=++x&&++y&&++z; printf(&quot;%d%d%d&quot;,x,y,z); }
1) First line in the &quot;main&quot; function is justdeclaration of variables of type &quot;int&quot; (without initialization).
2) Second line is initialization of these variables. Whenassignments are written in such sequential form it must be done from right to
left, that is firstly &quot;z=-1&quot; is executed, then the result of this
assignment (which is -1) is assigned to &quot;y&quot;, and then the result of
the last assignment &quot;y=z=-1&quot; (which is -1 again) is assigned to x.
Thus, all three variables x, y, z equals -1 after second line is executed.
3) Third line is the most complicated. It assignsexpression &quot;++x&&++y&&++z&quot; to variable z. Firstly
prefix increment of all three variables is executed: &quot;++x&quot;,
&quot;++y&quot; and &quot;++z&quot; (Since these increments are of prefix
variant, their priority is highest). After that values of these three variables
are greater by one then they were, that is now x, y and z equals 0. After that
logical operation AND (denoted as &quot;&&&quot;) is performed: firstly
++x AND ++y, and then the result of (++x AND ++y) with ++z. Since operands are
equal to zero they are interpreted as FALSE, and the result is FALSE itself
(that is zero too). Thus the whole result of this expression is zero. Then it
is assigned to the left part of assignment, that is &quot;z&quot;. But
&quot;z&quot; was zero already, so it is not changed. Summarizing, all three
variables are equal to zero.
4) The last line prints three variables x, y and z indecimal format (%d denotes integer in decimal format). So 000 will be printed on
display.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!