title: How does printf work? Why is the output different?
body: <p>Consider these two programs:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
    int z = 6.4;
    printf("%d %d", z, 6.4);
    return 0;
  }
  </code></pre>
  
  <p>Output is <code>6 -1717986918</code>.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
    int z = 6.4;
    printf("%d %d", 6.4, z);
    return 0;
  }
  </code></pre>
  
  <p>Output is <code>-1717986918 1075419545</code>.</p>
  
  <p>Why does the output vary like that? When <code>z</code> was first then the output printed correct <code>z</code> value which was <code>6</code> as <code>z</code> is an integer, but when I reversed the arguments, the output is a different value.  Why does it behave like that?</p>