Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavareWhat is the output of following code
#1
What will be output of following programs
[Image: IMG_20171130_WA0002.jpg]

Answer:
On line 4 of main program evaluation of right side will be done because of "=" operator. So right side as there are only logic operators RHS will be evaluated from Left to right

So from left side "||" comes first and therefore (++x) value is checked to be true/false value
And as we know ++x is a truthy value, further condition is not checked

So ++y && ++z is not executed

Finally z value = 1
x value is incremented by 1 (because of ++x)
And y value is 1 due to initial declaration

So ans = 2,1,1?
If you don't get this, pm me, i will help further.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)