``````#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iostream>

using namespace std;
For all 6-digit numbers from 100000 to 999999, find the numbers that, if you add the top three digits to the bottom three digits, and square the result, it will equal the original number.

For example, for 123456, you’d add 123 and 456, which equals 579. Then, square that sum, which yields 579 * 579 = 335241. 335241 ≠ 123456, so 123456 is not in the set

int main()
{
for ( int x =100000; x < 999999; x++)
{
//cout<< x <<endl;
int sum,result;
int firstpart= x/1000;
int secondpart =x%1000;
sum = firstpart + secondpart;
result=sum*sum;
if (x=result)
{
cout<<result<<endl;
}

system("PAUSE");
return 0;

}
``````

line 22: use == operator, not the = assinment operator.

thank u .it worked for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.