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.
i have being able to generate six digit numbers but can't add first three to the second three.any help for me please.do u think arrays can work out here.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
for ( int x = 100000; x < 999999; x++ )
{
cout<< x <<endl;
int first3;
int second3 ;
}
system("PAUSE");
return 0;
You can get the top 3 digits by dividing each number by 1000
And you get the bottom 3 by doing number % 1000
E: you can make your search easier by starting at the first 3 digit number that when squared will equal a 6 digit number (317) and end at 999. Then for each number, you square it and add the first 3 digits to the bottom 3. If you don't get the number you squared, this is not one of them
i have an issue sir,am not able to capture the first 3 digits to add to the last 3 digits.please can u assist me.this my line of code so far.
{
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;
cout<<firstpart<< "and" <<secondpart<<"="<<sum<<" " "the square is"<<result<<endl;