Pre increment operator in C program

Consider the following C program.

Which of the following represents the output of above program?

here answer is -2 3 0 1

 

 

Doubt:

 

k is also pre incremented so why is k value not 1?

 

 

 

5Comments
Shraddha @shraddhagami
29 Jan 2017 09:33 pm

@nature

The operation 'or' is in between so if 1st condition is true then don't go for 2nd condition.(b'cz true || something is true)

If first condition is false then it will go for 2nd condition.(if first condition is false then result is depend on 2nd condition)

Rahul @rahul55523
3 Feb 2017 11:48 am

https://www.programiz.com/c-programming/precedence-associativity-operators

but i have doubt , if you see precedence and associativity uniary higher precedence than binary operation i guess k's value will be change 

nature @natureearth
3 Feb 2017 01:47 pm

in that case j will be incremented first and then i,but because there is Logical OR it will execute the left side operation first.

sonali @sonalirangwani
30 Jan 2017 10:41 am

correct explanation!!

nature @natureearth
2 Feb 2017 09:38 pm

thanks shraddha

Pages