Monday
May 4, 2015

Homework Help: algorithm

Posted by alberto on Thursday, July 17, 2008 at 10:13pm.

can someone tell me if this is correct.
Write an algorithm that will display the sum for a given number of squares. In other words if the user enters the value 5, then the output should be 1^2 + 2^2 + 3^2 +4^2 + 5^2 = 55.
sumsquare integer
square integer
count integer
sumsquare := (y^2)
square := 1^2
count := 1
dowhile count = (x)
count = count + 1
sumsquare = sumquare + square
enddo
print\n "sumsquare is ", sumsquare

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Members