title: Explanation regarding output of C program
body: <pre><code>void count(int n) 
  { 
      static int d=1;
      printf("%d", n);
      printf("%d", d);
      d++;
      if(n&gt;1)
          count(n-1);
      printf("%d", d);
  }
  
  void main()
  {
      count(3);
  }
  </code></pre>
  
  <p>Output calculated by me is 3 1 2 2 1 3 4</p>
  
  <p>And Output given by book 3 1 2 2 1 3 4 4 4</p>
  
  <p>I know why my answer different.</p>
  
  <p>In book solution they are executing printf statement in "if" loop always. But as I study in my book scope of if, for and while loop is up to next statement if parentheses are not present.</p>
  
  <p>After if statement true count is called and printf not get executed. But why they are executing it each time.</p>