Given the values of A=3, B=4 and C=5, what is the final value of variable C when C=B++; B=A; B=--C?
Answers
Answered by
1
Answer:
finally c = 3
Explanation:
initially
a = 3
b = 4
c = 5
c = b++ (post increment)
hence c = 4
b = 5;
b = a => b = 3;
b = --c(pre decrement)
b = 3 and c = 3
Answered by
0
A = 3 , B=4 , C=5
The statements that are executed are:
1) C= B++;
As this is post increment, so the updated value is stored in B but not returned to C, so the value of B is returned to C.
So, C=4 , B=5, A=3
2) B=A;
Now, B=3, A =3, C=4.
3) B= --C;
As it is pre decrement, so the updated value of C is returned to the variable C as well as to B.
Now, B= 3 , C=3, A=3. (Final values)
So, the final values of C is 3.
Similar questions