You are on page 1of 1

Atienza, Lara Denniece L.

IB-BSIS

1. Complete the desk-check table. What will the code display on the screen? What is the value in
the temp variable when the loop stops?
Result:
temp 0
temp 1
temp 2
temp 3
temp 4
** When the value of temp is 5 the loop will stop.
2. Complete the desk-check table. What will the code display on the screen? What is the value in
the totEmp variable when the loop stops?
Result:
totEmp 0
totEmp 2
totEmp 4
** When the value of totEmp is 6 the loop will stop.
3. Write an assignment statement that updates a counter variable named numStudents by 1.
numStudents = numStudents + 1;
4. Write an assignment statement that updates a counter variable named quantity by -5.
quantity = quantity + -5; (or quantity = quantity – 5;)
5. Write an assignment statement that updates an accumulator variable named total by the
value in the sales variable.
total = total + sales;
6. Write an assignment statement that updates an accumulator names total by the value in the
gross variable.
total = total + gross;
7. Complete the desk-check table. What will the code display on the screen? What is the value in
the temp variable when the loop stops?

Input Output Loop


0 temp 1 +1
1 temp 2 +1
2 temp 3 +1
3 temp 4 +1
4 temp 5 0

8. Complete the desk-check table. What will the code display on the screen? What is the value in
the temp variable when the loop stops?
Input Output Loop
0 num 2 +2
2 num 4 +2
4 num 6 0

You might also like