223k views
2 votes
run the following algorithm and write the result step 1 sum=0 step 2. for i=8 up to 10 do step 3. sum=sum+i^2 step 4 output(sum)

1 Answer

5 votes

Answer:

245

Explanation:

This is an accumulator algorithm where the current value of variable sum increases by the square of

sum = 0

When i = 8, sum = 0 + 8² = 0 + 64 = 64
When i = 9, sum = 64 + 9² = 64 + 81 = 145
When i = 10 sum = 145 + 10² = 145 + 100 = 245

Final value of sum = 245

User Nishant Gupta
by
9.0k points