Suppose a, b and c are int variables where a = 4 and b =7. Supposed and e are do
ID: 3612844 • Letter: S
Question
Suppose a, b and c are int variables where a = 4 and b =7. Supposed and e are double
variableswhere d =2.5. What value isassigned to each variable after the statements execute?(Remember,
thestatements are executed in sequence.) If a variable is undefined ata particular statement, report UND
(undefined).
a b c d e
a = (++b) * 2;_____ _____ _____ _____ _____
c = (a--) - 6;_____ _____ _____ _____ _____
d *= a - (c++) -2; _____ _____ _____ _____ _____
b += c * (++d) -a * 7; _____ _____ _____ _____ _____
e = d - (a % c) + (b++); __________ _____ _____ _____
Explanation / Answer
a b c d e
start 4 7 UND 2.5 UND
a = (++b) *2 16 8 UND 2.5 UND add 1 to be (since ++b do first) then mult by2
c = (a--) -6 15 8 10 2.5 UND sub 6 from a then sub 1 from a (since a- -do after=)
d *= a - (c++) – 2 15 8 11 7.5 UND c++ so do after mult; *= means d=d*quantity
b += c * (++d) - a *7; 15 -3 11 8.5 UND ++d so do beforetheaddition
e = d - (a % c) +(b++); 15 2 11 8.5 1.5 add to b after the=
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.