1. Trace through the following statements, showing the result of executing each
ID: 3906170 • Letter: 1
Question
1. Trace through the following statements, showing the result of executing each one in the sequence shown (create a "memory snapshot"). SHOW ALL WORK. int b:3, c-2; double d, P,V-5.4; dev+b/ ctt 2. Translate the following into equivalent C statements a. Declare a variable named pizzas and assign to it a whole number between 1 and 7, endpoints included. Pizzas- 5) b. More people arrive for lunch! Update the value stored in pizzas by adding 3. piezes piezas 13, Declare a variable named price and assign to it the cost of each pizza (they all have the same price-your choice, but remember the price of a pizza should reflect fractions of dollars as well as whole dollars). c. Declare a variable named bill and assign to it the cost of all the pizzas (computed using only variables), plusa tip for the delivery person (be generous). d. int tip 5Explanation / Answer
According to chegg guidelines i have to solve first question only.
1.
Initially the values of variables
b=3,c=2 and v=5.4
d=v+b/c;
d=5.4+3/2;
The execution based priority order.
Divided by(/) has high priority than plus(+)
3/2 = 1.5
Since data is int type so it discard the floating point value so .5 is discarded 3/2 = 1
d=5.4+1;
d=6.4;
c++;
The value is incremented by 1
c=2+1;
c=3;
p=d-b*c%2;
Here priority order of operators (High tolow) : * , % and -
p=d-b*c%2;
p=d-3*3%2;
p=d-9%2; // 9%2 means reminder of when 9 / 2 operation that is reminder 1
p=6.4-1;
p=5.4;
v=b+(c-5)*p-d;
v=3+(3-5)*5.4-6.4;
Here priority order of operators (High tolow) : (),* , + and -
v=3+(3-5)*5.4-6.4;
v=3+(-2)*5.4-6.4;
v=3+-10.8-6.4;
v=-7.8-6.4;
v=-14.2;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.