View Single Post
Old 08-22-2006, 06:15 AM   #1 (permalink)
Jove
Groovy Hipster Nerd
 
Jove's Avatar
 
Location: Michigan
Solve this simple programming assignment

Alright, this might be a simple programming solution for most, but I would like to know what you would do the following question:

Design the logic for a module that would print number 1 through 10 along with its square and cube.

Example:

Printonethroughten()
Number = 1
While number <= 10
Print number
Number = number + 1
End while
Return

This was the example given and I assumed, one would have to do this to get the square

Printonethroughten()
number = 1
while number <= 10
print number
number = number + 1 * number
End while
Return

Cube

Printonethroughten()
number = 1
while number <= 10
print number
number = number + 1 * number * number
End while
Return

---
Was the above solution the correct answers or incorrect answers?
Jove is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60