C++ keeps skipping my "for" loop : <p>I'm trying to create a program that will find a four-digit number that meets four specific requirements: all four digits are different, the thousands number is 3x the tens number, the number is odd, and the sum of the digits is 27. For some reason, despite the program compiling, the for loop won't run and always outputs the initializer number (1000). My main code and the four functions I'm calling are below. I can't figure out why it won't run correctly. I'm completely new to coding so any tips/help are appreciated. Thanks!</p>

<p>main function:</p>

<pre><code>      5 //prototypes
      6 bool differentDigits(int);
      7 bool thouThreeTen(int);
      8 bool numberIsOdd(int);
      9 bool sumIs27(int);
     10 
     11 #include &lt;iostream&gt;
     12 using namespace std;
     13 
     14 int main ()
     15 {
     16         //variables
     17         int n;
     18 
     19         //processing
     20 
     21         for(n=1000;n&lt;=9999;n++)
     22         {
     23                 if(differentDigits(n)==true)
     24                 {
     25                         break;
     26                 }
     27 
     28                 if(thouThreeTen(n)==true)
     29                 {
     30                         break;
     31                 }
     32 
     33                 if(numberIsOdd(n)==true)
     34                 {
     35                         break;
     36                 }
     37 
     38                 if(sumIs27(n)==true)
     39                 {
     40                         break;
     41                 }
     42 
     43         }
     44 
     45         //output
     46         cout &lt;&lt; n &lt;&lt; endl;
     47 
     48         return 0;
     49 }
</code></pre>

<p>differentDigits function:</p>

<pre><code>      3 //Verify all four digits are the same
      4 
      5 #include &lt;iostream&gt;
      6 using namespace std;
      7 
      8 bool differentDigits (int n)
      9 {
      10         int n1, n2, n3, n4;
      11 
      12         n1 = n/1000;
      13         n2 = (n/100) % 10;
      14         n3 = (n/10) % 10;
      15         n4 = n % 10;
      16 
      17         if(n1 != n2 != n3 != n4)
      18         {
      19                 return true;
      20         }
      21         else
      22         {
      23                 return false;
      24         }
      25 
      26 }
</code></pre>

<p>thouThreeTen function:</p>

<pre><code>      3 //Verify digit in thousands place is 3x the digit in tens place
      4 
      5 #include &lt;iostream&gt;
      6 using namespace std;
      7 
      8 bool thouThreeTen(int n)
      9 {
      10         int n1, n2, n3, n4;
      11 
      12         n1 = n/1000;
      13         n2 = (n/100) % 10;
      14         n3 = (n/10) % 10;
      15         n4 = n % 10;
      16 
      17         if(n1 = (n3 * 3))
      18         {
      19                 return true;
      20         }
      21         else
      22         {
      23                 return false;
      24         }
      25 
      26 }
</code></pre>

<p>numberIsOdd function:</p>

<pre><code>      3 //Verify that the number is odd
      4 
      5 #include &lt;iostream&gt;
      6 using namespace std;
      7 
      8 bool numberIsOdd (int n)
      9 {
      10         if((n % 2)==1)
      11         {
      12                 return true;
      13         }
      14         else
      15         {
      16                 return false;
      17         }
      18 
      19 }
</code></pre>

<p>sumIs27 function:</p>

<pre><code>      3 //Verify that the sum of digits is 27
      4 
      5 #include &lt;iostream&gt;
      6 using namespace std;
      7 
      8 bool sumIs27(int n)
      9 {
      10         int n1, n2, n3, n4;
      11 
      12         n1 = n/1000;
      13         n2 = (n/100) % 10;
      14         n3 = (n/10) % 10;
      15         n4 = n % 10;
      16 
      17         if((n1+n2+n3+n4)==27)
      18         {
      19                 return true;
      20         }
      21         else
      22         {
      23                 return false;
      24         }
      25 
      26 }
</code></pre>
