edited by
1,504 views

2 Answers

1 votes
1 votes

Here we have $3$ operators: brackets, conditional operators, and assignment operators. The precedence of operators is as follows:

  1. Brackets
  2. Conditional operator
  3. Assignment operator

So expression $i+=(f>3)?i\&2:5$ will be evaluvted :

The conditional operator first checks the condition if it is true  $i\&2$ will be evaluated. if the condition is false then $5$ will be considered.

$(f>3)=11>3$, because it is relational operator it will gives either $0/1$. condition is true so it will execute $i\&2$ (bitwise and) and gives $2$ as output.

now our expression becomes $i+=2\implies i=i+2\implies i=3+2=5$

Option $(B)$ is correct.

0 votes
0 votes

NOTE: May be there is typo in this question.

 

Proper Question:

int f = 11, i = 3;
i+ = (f >3)? i & 2:5;

 

Ans: 5

Since initial value of i = 3;

(f > 3) will evaluates to true hence (i&2) will be executed i.e (3 & 2) while will give 2.

Final Expression: i+=2;   → 5.

 

Related questions

2 votes
2 votes
6 answers
1
go_editor asked Mar 27, 2020
2,224 views
What is the output of the following $C$-programmain() { printf("%d %d %d",size of (3.14f), size of (3.14), size of (3.141)); }4 4 44 8 108 4 88 8 8
1 votes
1 votes
1 answer
2
0 votes
0 votes
1 answer
3
go_editor asked Mar 27, 2020
408 views
The Register or main memory location which contains the effective address of the operand is known as:PointerIndexed registerSpecial LocationsScratch Pad
0 votes
0 votes
1 answer
4
go_editor asked Mar 27, 2020
402 views
A Top - down Parse generatesLeft most derivationRight – most derivationRight most derivation in reverseLeft – most derivation in reverse