title: Basic question about how this C code is working
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  
  int get_pos_int(void);
  
  int main(void) {
      int i = get_pos_int();
      printf(&quot;You entered the positive Integer of %i\n&quot;, i);
  }
  
  int get_pos_int(void) {
      int n;
      do {
          n = get_int(&quot;Insert a positive Integer: &quot;);    
      }
      while(n &lt; 1);
      return n;
  }
  </code></pre>
  <p>So of course this is just a simple program to test for if a number entered is a number above 0. Out of interest I decided to make this small change to see if it was semantically still correct.</p>
  <pre><code>int main(void) {
      get_pos_int();
      printf(&quot;You entered the positive Integer of %i\n&quot;, get_pos_int());
  }
  </code></pre>
  <p>When running the program with this change, if I input the number '1' it returns me back to the prompt to type an integer, then if I type 1 again it returns 'You entered the positive Integer of 1'</p>
  <p>I was just wondering if you could explain what the behaviour is causing this, I like to know why things are working the way they are and it interested me how removing the function being stored in a variable made it behave this way.</p>