67 108
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #44167 in C for nitesh kumar yadav

Question #44167
#‎include‬ <stdio.h>
int main()
{
int x = 0,y = 0, z;
z = ++x || ++y;
printf("%d %d %d",x,y,z);
}
its output will be x=1 y=0, z=1.
how it is print y=0? give me reason please
Expert's answer
#include <stdio.h>
int main()
{
int x = 0, y = 0, z;
z = ++x || ++y;
printf("%d %d %d", x, y, z);
}
Yes, its output will be x=1, y=0, z=1. This happens because of optimisation: when "z = ++x || ++y;" is processed, x is being incremented and the entire expression is TRUE. As there is logical OR in this expression, further elements will be ignored for optimisation purposes.
You could also try to exchange the order: "z = ++y || ++x;", and ypu'll get the following result: x=0, y=1, z=1 - as you can see, same thing occured and x isn't incremented.

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions