title: How can I debug my while loop C++ program?
body: <p>Please disregard some of the undeclared variables. I do not really know what is wrong.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
    int number{}, tries{}, ans{}, count{};
  
     cout &lt;&lt; "Enter an integer greater than 0: ";
     cin &gt;&gt; number;
  
     while (number &gt; 0){
          ans = number / 10;
          ++count;
          if (ans == 0){
              cout &lt;&lt; "The number has " &lt;&lt; count &lt;&lt; "digits";
              break;
          }
     }
  
      return 0;
  }
  </code></pre>