0

What's execution sequence and priority in given code

#include <stdio.h> int main() { int a=-10,b=3,c=0,d; d=c++ && ++b || a++; /* which condition is executed first and second? */ printf("%d, %d, %d, %d",a, b, c, d); return 0; } My question is when we get one entity as nonzero then we don't need to evaluate other for logical OR then how a incremented?

23rd Nov 2018, 1:41 PM
Akshay Kumbhar
Akshay Kumbhar - avatar
1 Odpowiedź
+ 15
● Predence of && operator is more than that of || operator (so && opearator will be evaluated 1st) ● Associativity is from left to right [no role of it here][for both && and || ](so will start seeing from left then move to right) ●for precedence & associativity in post & pre increment operator check my answer in this post https://www.sololearn.com/Discuss/1595675/?ref=app NOTE : this is for C language .
23rd Nov 2018, 1:51 PM
Gaurav Agrawal
Gaurav Agrawal - avatar