title: Displaying the number of iterations - C++
body: <p>Here's the code to find Lychrel numbers (it's not perfect as of yet, but that's not important to the question:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int Reverse(int number)
  {
      int rem = 0;
      while (number &gt; 0)
      {
      rem = (rem * 10) + (number % 10);
          number = number / 10;
      }
      return rem;
  
  }
  
  bool is_Palindrome(int num)
  {
      return (num == Reverse(num));
  }
  
  bool isLychrel(int num, const int iterCount = 50)
  
  {
      int temp = num;
      int rev;
      for (int i = 0; i &lt; iterCount; i++)
      {
  
          rev = Reverse(temp);
          if (is_Palindrome(rev + temp))
              return false;
          temp = temp + rev;
      }
      return true;
  
  }
  
  int main()
  {
  
      bool l = isLychrel(some number);
      std::cout &lt;&lt; l &lt;&lt; "\n";
  
      return 0;
  
  } 
  </code></pre>
  
  <p>What I want to do is, other than to display whether or not it is a Lychrel number, I want to show how many iterations it took for the palindrome to be discovered. So I know I have to define an int i = 0, but I don't know where and I don't know how to make it work. I tried to do it outside of the loop, like this:</p>
  
  <pre><code>int i = 0;
  {
      int temp = num;
      int rev;
      for (int i = 0; i &lt; iterCount; i++)
      {
  
          rev = Reverse(temp);
          if (is_Palindrome(rev + temp))
              return false;
          temp = temp + rev;
      }
      return true;
  
  } 
  </code></pre>
  
  <p>but I get the error "expected unqualified-id before "{" token" and "expected initializer before 'int'". I'm at a loss on where to put it to make it work. </p>