#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
i need some help please.

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;
         if (x=result)

            return 0;


Recommended Answers

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

Jump to Post

All 2 Replies

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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.