Predict the output of the following code. 

Justify. 

int k = 5; 

b = 0; 

b = k++ + ++k; 

cout<

4 views

1 Answers

Output is 12. In this statement first it take the value of k in 5 then increment it K++. So first operand for + is 5. Then it becomes 6. Then ++k makes it 7. This is the second operand. Hence the result is 12.

4 views