Magic square problem C++? ?

Magic square problem C++? ?
how do i make program in which computer tell me what are the perfect squares.

Ex. 6^2 = 36 which sum of 1.. to.. 8 = 36

how do i make it program using loop so it give me that 36 is perfect squrs and it would find next one (1225) and next one and so on...(i think max u can find it 4 or 6).

can you show me loop example? for this type of problem?
Last edited on
umm if I get what you're asking you can use a simple loop where you multiply the number by itself... something like

for(int i = 1; i <=8; i++)
{
result = i*i;
//output result here
}

You could also use math's pow to make your function a lot more versatile.
Last edited on
Topic archived. No new replies allowed.