866 views

2 Answers

Best answer
12 votes
12 votes
int a = 1, b = 2;
int c = a++ || b++;

2nd statement will run a++ and then there is logical OR operator so it will halt. (Short Circuit Rule for logical operators in C).

c = 1,
a = 2,
b = 2 (unaffected)
selected by
1 votes
1 votes

    int c = a++ || b++;

The logical OR would stop as soon as it finds any positive value ($\equiv$ 1). It stops right at a.

So, c = a

=> c = 1

 

Now, a++

=> a = 2

 

And b is never touched.

So, 2,2,1.

Option C

Answer:

Related questions

3 votes
3 votes
2 answers
2
8 votes
8 votes
2 answers
3
1 votes
1 votes
3 answers
4