title: one month calendar in c
body: <p>I'm trying to make a one-month calendar in C.  This code <em>kind of</em> works, but for some inputs the spacing is off. I don't quite know how to fix it.  </p>
  
  <p>Also, if you have a way of making a one month calendar that involves less code than this, that would be great, since I have to regurgitate this on a test in about an hour.  </p>
  
  <p>Thanks!</p>
  
  <pre><code>int main() {
  
      int spaces, days_in_month, day_of_week, i;
  
      printf("Please enter the numier of days in the month:\n");
      scanf("%d", &amp;days_in_month);
  
      printf("Please enter starting day of the week:\n");
      scanf("%d", &amp;day_of_week);
  
      spaces = day_of_week - 1;
  
      printf("Here's your calendar:\n");
  
      for (i=0; i&lt;spaces; i++)
          printf("   ");
  
  
      for (i=1; i&lt;=(7-spaces); i++)
          printf("  %d", i);
  
      printf("\n");
  
      if ((i-spaces) &gt;10 &amp;&amp; (i-spaces) &lt; 14-spaces)
          printf("   ");
  
      for (i=(8-spaces); i&lt;=(10-spaces); i++)
          printf("  %d", i);
      for (i=(11-spaces); i&lt;=(14-spaces); i++)
          printf(" %d", i);
  
      printf("\n");
  
      for (i=(15-spaces); i&lt;=(21-spaces); i++)
          printf(" %d", i);
  
      printf("\n");
  
      for (i=(22-spaces); i&lt;=(28-spaces); i++)
          printf(" %d", i);
  
      printf("\n");
  
      for (i=(29-spaces); i&lt;=days_in_month; i++)
          printf(" %d", i);
  
      return 0;
  
  }
  </code></pre>