give the initial value of r = 5 in the expression v=r++ + 2*r + 2*r++
Answers
Answered by
6
Required Answer:-
Given:
- r = 5
To Find:
- The final values of v and r when v = r++ + 2*r + 2*r++
Solution:
Given that,
→ r = 5
Now,
→ v = r++ + 2*r + 2*r++
→ v = 5 + 2*r + 2*r++ (r is 5 due to post increment)
→ v = 5 + 2*r + 2*r++ (r becomes 6)
→ v = 5 + 2*6 + 2*r++ (substituting the value of r)
→ v = 5 + 12 + 2*6 (r is 6 due to post increment)
→ v = 5 + 12 + 12 (r becomes 7)
→ v,r = 29, 7 (Final value)
→ Hence, the values of v and r are - 20 and 7
Answer:
- v = 29.
- r = 7.
Refer to the attachment.
Attachments:
Similar questions