1,833 views

2 Answers

Best answer
15 15 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
2 2 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:
Position:
Show:

Related questions

6 6 votes
1 1 answer
3.3k
3.3k views
Arjun asked Oct 18, 2016
3,303 views
Consider the following incomplete C function for reversing a singly linked list.node* reverse(node* trav){ if(trav->next) __________________ else { head - next = null; he...
9 9 votes
2 answers 2 answers
2.4k
2.4k views
Arjun asked Oct 18, 2016
2,415 views
int foo(int n) { if(n 10000) return 1; int sum = 0, i; for( i = 0; i < n; i++) { sum += i; } return sum; }The value returned by the above function is$\Theta\left(n^2\rig...
8 8 votes
1 answers 1 answer
3.2k
3.2k views
Arjun asked Oct 18, 2016
3,208 views
int foo1(float a) { int b = a; return b/2; } int foo2(double a) { int b = a; return b/2; } int foo3(unsigned int a) { int b = a; return b/2; }Consider the above three C f...
9 9 votes
2 answers 2 answers
4.7k
4.7k views
Arjun asked Oct 18, 2016
4,668 views
Which of the following statements is correct?S1: A struct object will always occupy more space than an union object having the same elements.S2: Given an int array Arr an...