##### && and ++ operator in C

what is output?

28 Jan 2017 11:09 pm

Z=5

Anjali
3 May 2017 03:59 pm

if any operand in logical and(&&) is non-negative then output will be false

so in this exprssion z doesnot gets increemented

therefore z  remains 5

Sourav Pal
3 May 2017 04:03 pm

5

Pritam Prasun
4 May 2017 12:55 pm
@souravpal, Please do not repeat the same answer as given by someone else on the same question.
shivani
4 May 2017 08:22 pm
• this question is based on short circuiting concept .
• here (x && y && z++)// x=1,y=0,z=5
• when (x && y ) is done, we get 0 ; so basically ANDing of anything with 0 is 0, so here shortcircuiting comes into picture and any operation later on is ignored(i.e. z++).
• due to this reason z=5.
papesh
5 May 2017 12:25 am

but ++ operator having higher precedence than && operator ...so why not z++ is executed first ??