title: Project Euler Problem 4
body: <p>I've created a solution to problem 4 on Project Euler.
  However, what I find is that placing the print statement (that prints the answer) in different locations prints different answers. And for some reason, the highest value of result is 580085. Shouldn't it be 906609? Is there something wrong with my isPalindrome() method?</p>
  
  <pre><code> #include &lt;stdio.h&gt;
   #include &lt;stdbool.h&gt;
  
   int isPalindrome(int n);
  
   //Find the largest palindrome made from the product of two 3-digit numbers.
   int main(void)
   {    
        int i = 0;
        int j = 0;
        int result = 0;
        int palindrome = 0;
        int max = 0;
  
        //Each iteration of i will be multiplied from j:10-99
        for(i = 100; i &lt;= 999; i++)
        {
              for(j = 100; j &lt;= 999; j++)
              {
                    result = i * j; 
                    if(isPalindrome(result) == 0)
                    {
                         //printf("Largest Palindrome: %d\n", max); //906609
                         //printf("Result: %d\n", result); //580085
                         if(result &gt; max)
                         {
                              max = result;
                              //printf("Largest Palindrome: %d\n", max); //927340
                         }      
                         printf("Largest Palindrome: %d\n", max); //906609
                    }
              }
         } 
  
         //printf("Largest Palindrome: %d\n", max); //998001
  
        system("PAUSE");
        return 0;
   } //End of main
  
   //Determines if number is a palindrome
   int isPalindrome(int num)
   {
        int n = num;
        int i = 0;
        int j = 0;
        int k = 0;
        int count = 0;
        int yes = 0;
  
        //Determines the size of numArray
        while(n/10 != 0)
        {
             n%10;
             count++;
             n = n/10;
        }
  
        int numArray[count];
  
        //Fill numArray with each digit of num
        for(i = 0; i &lt;= count; i++)
        { 
             numArray[i] = num%10;
             //printf("%d\n", numArray[i]);  
             num = num/10;
        }
  
        //Determines if num is a Palindrome     
        while(numArray[k] == numArray[count])
       {
             k = k + 1;
             count = count - 1;  
             yes++;
        }
  
        if(yes &gt;= 3)
       {
             return 0; 
        }
  
  }//End of Function
  </code></pre>