Free help with homework

Why join Brainly?

  • ask questions about your assignment
  • get answers with explanations
  • find similar questions

What will be the output(step by step) for the following-

if t=10.
1) t-=++t+(--t)*2
2)t+=t-- + ++t+ --t
ans for each case

can you please rate the answer and i hope the step by step answer is clear.



This Is a Certified Answer

Certified answers contain reliable, trustworthy information vouched for by a hand-picked team of experts. Brainly has millions of high quality answers, all of them carefully moderated by our most trusted community members, but certified answers are the finest of the finest.
For 1)    t = - 18 after the statement is executed
               --t is done first.  so t becomes 9. u get 18 to right of +.  ++t gives 10. and on left of  + we have 10.  RHS of -= we have 28. t is now 10. 

  for 2)  t = 38    after the statement is executed
         --t is done first. so t=9. RHS =9.  ++t is 10 and t become 10. RHS is now 19. t-- gives 10 value and t becomes now 9.  RHS of += 29. 

0 0 0
Write t -= (++t ) + (--t) * 2 . In this first --t will be done. t =9. E1=9. Then multiplication of E1 by 2. So E1 = 18. Then ++t will be done. So t = 10. E2 = 10. Then results E1 and E2 are added. So we get t -= 28. As t is 10 at this point, this will result in -18.
write t += (t--) + (++t) + (--t) In this first --t is done. So t is 9. yu get E1 = 9. next ++t is done. so t becomes 10. E2 = 10. Now t-- is done. so t = 9. But E3 = 10 and not 9 as post-fix operator is used. Now add E1, E2, E3 to get 29. It becomes now t += 29 As t =9 at this point of time, t will become 38.
t+=t dosnt mean t= ++t !!
t += x means that t = old value of t + value of expression x
If we dont understand the values, try a program online and see result
The Brain
  • The Brain
  • Helper
Not sure about the answer?
Learn more with Brainly!
Having trouble with your homework?
Get free help!
  • 80% of questions are answered in under 10 minutes
  • Answers come with explanations, so that you can learn
  • Answer quality is ensured by our experts