1. ## Palindromic numbers problem

I wrote a program to find the largest palindromic number one could produce as the product of two three digit numbers.

Code:
```int main (void)
{
int i, j, z;
int num;
char buf[6];
char test[6];

for(i=100; i<=999; i++)
{
for(j=100; j<=999; j++)
{
num = i * j;

sprintf(buf, "%d", num);

for(z=0; z<=6; z++)
test[z]=buf[z];

int len=strlen(buf);

for(z=0; z<len/2;z++)
{
test[z]^=test[len-z-1];
test[len-z-1]^=test[z];
test[z]^=test[len-z-1];
}

/*puts(buf);*/
/*puts(test);*/
/*printf("\n");*/
if(test == buf)
puts(buf);

}
}

return 0;
}```
I'm having problems withe the
Code:
`if(test == buf)`
part. I know the program produces the correct answer (906609), but when I run it, nothing ever ends up being printed. Should I be comparing the two arrays differently?

2. This accesses the arrays out of bounds because of the use of <= instead of < :
Code:
```for(z=0; z<=6; z++)
test[z]=buf[z];```
Actually, you have another problem. 999 * 999 = 998001, which when converted to a numeric string would require 6+1=7 characters, so your arrays are not big enough.

Also:
Code:
```test[z]^=test[len-z-1];
test[len-z-1]^=test[z];
test[z]^=test[len-z-1];```
Use a conventional swap involving a "temporary" variable instead.