I was trying to solve project Euler problem 4 which is:
A palindromic number reads the same both ways. The largest palindrome made from the product of tw
Done in C. This might help you.
#include
int calculate(int n)
{
int temp = 0,m = 0;
m = n;
while(n != 0)
{
temp = temp * 10;
temp = temp + n % 10;
n = n / 10;
}
if(m == temp)
{
printf(" %d \n",temp);
return temp;
}
else
{
return 0;
}
}
int main()
{
int i,j,temp = 0,count=0,temp1 = 0;
for(i = 100;i < 1000;i++)
{
for(j = 100;j < 1000;j++)
{
temp1 = i * j;
temp = calculate(temp1);
if(temp > count)
{
count = temp;
}
}
}
printf(" The Largest Palindrome number is : %d \n",count);
}