retagged by
1,666 views
0 votes
0 votes

What is the value of $‘b’$ after the execution of the following code statements :

$C=10;$

$B=++c + ++c;$

  1. $20$                 
  2. $22$       
  3. $23$                 
  4. None
retagged by

2 Answers

–1 votes
–1 votes
23 is the answer

Case 1:

c=10;

b= ++c + ++c;

Then, b=11 + ++c (as ++c means 1st increment and then assignment, so c+1=10+1=11)

Then b= 11 + 12 (same as above)

So, b=23

Case 2:

c=10;

b= ++c++ +c;

Then, ++c means c value(10) at 1st increment then assignment , so 11 (++c) will get added to the value of c after c++ operation

Again c++ means 1st assignment then increment

After increment(i.e., c++), c =12

Now b=11+12 =23

Related questions

1 votes
1 votes
3 answers
2
0 votes
0 votes
1 answer
3
rishu_darkshadow asked Sep 22, 2017
1,351 views
There exists a construct which returns a value ‘true’ if the argument subquery is :empty non-empty in error none of the above
1 votes
1 votes
1 answer
4
rishu_darkshadow asked Sep 22, 2017
2,400 views
The friend functions are used in situations where :We want to have access to unrelated classes Dynamic binding is required Exchange of data between classes to take...