143k views
5 votes
What is the value of count after the last iteration of the outer for loop? Be sure to show your work.

count :=0

For i= 1 to 2

For j=1 to 2

count :=j(count-i)

End-for

End-for

User Harijay
by
5.2k points

1 Answer

7 votes

Answer:

count := -16

Explanation:

Let's compute this step by step

count starts at 0

Then i is equal to 1

Then j = 1

count := 1(0-1) := -1

Now j = 2

count := 2(-1-1) := -4

Now i =2 and j = 1

count := 1(-4-2) = -6

Now j = 2

count := 2(-6-2) = -16

End

End

So, after the last iteration of the outer for loop, count is equals to -16.

User Glicuado
by
5.3k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.