Calculating pythagorean triples
<p>I was writing some code to calculate Pythagorean triples, but then I got some values which were not solutions. Here is the code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;math.h&gt;

using namespace std;

int main()
{
int j, counter = 0;
double candidate, sqrnbr;
for (int i = 400; i &lt;= 500; i++) //note that the range is only from 400-500 since I am still testing the code
{
    for (j = i; j &lt;= 500; j++)
    {
        candidate = i*i+j*j;
        sqrnbr=sqrt(candidate);
        if (candidate/sqrnbr==sqrnbr)
        {
           cout &lt;&lt; i &lt;&lt; " and " &lt;&lt; j &lt;&lt; " and " &lt;&lt; sqrnbr &lt;&lt; endl;
           counter++;
        }
    }

}
cout &lt;&lt; counter &lt;&lt; endl;
system("pause");
return 0;
}
</code></pre>

<p>One of the outputs it gave was 408, 410 and 578.415. Does anyone know why this happens?</p>
