Perfect squares

Hello!As I am a beginner I have a question to a program that I want to make.
I need to do the sum of the elements that are perfect square. It is not hard to do ,but I don`t know what condition I need to put in if(...)so that the program would select only the perfect square numbers and sum them. Again ,I only want the condition. Thank you !
I know what a Square number is and I know what a Perfect number is, but what is a Perfect Square?
this sounds like a interresting question, but i do not know exactly what you want to do...
ohh,sorry I formulated wrong . What I mean is that I want to make me the sum of all the square numbers . Something like
1
2
3
4
5
6
 36
25
49
5
6
sum=25+49+36

I`m not good at explaining ,but something that would calculate the square numbers . I Guess
I just want to know if there is a way to make that statement in a if(...)
Last edited on
A perfect square, is an integer that is the square of some integer.

1
2
3
4
5
6
7
8
int number /* = whatever */ ;
for( int i=0 ; i<number ; ++i )
{
    if( number == i*i )
    {
        // the number is a perfect square
    }
}
What's your input? A list of numbers (e.g. {40, 49, 60, 81, 100, 32}) , or an upper bound (e.g. "all numbers below 1000")?
In fact I have solved the Problem . I just had to use the sqrt function. I didn`t explain too well. Sorry for the trouble and thank you for your help.
Topic archived. No new replies allowed.