Hi, I am doing Question 4 of the Project Euler puzzles. I wrote some code which is supposed to find the biggest palindrome from the product of 2 numbers. However, this always prints out 900099. I cannot really find any errors in this code, but if you do, please let me know. Any helpful tips on making better code using a different approach is greatly appreciated (my approach was not that great).
#include <iostream>
using namespace std;
bool ispalindrome(int);
int main()
{
int biggestpal;
int indicator = 0;
for (int i = 999; i >= 100 && indicator == 0; i--)
{
for (int j = 999; j >= 100; j--)
{
biggestpal = i * j;
if (ispalindrome(biggestpal))
{
cout << biggestpal;
indicator = 1;
break;
}
}
}
return 0;
}
bool ispalindrome(int number)
{
int first,second,third,fourth,fifth,sixth;
first = number/100000;
second = number % 100000;
third = number % 10000;
fourth = number % 1000;
fifth = number % 100;
sixth = number % 10;
if (first == sixth && second == fifth && third == fourth)
return true;
else
return false;
}