title: Printing a calendar with month and year in C
body: <p>I'm trying to make a program that will print out the month from the given year and month that the user inputs. What I have so far just ends up printing out the entire calendar year. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int determineleapyear(int year);
  int days_in_month[]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
  char *months[]=
    {
      " ",
      "\n\n\nJanuary",
      "\n\n\nFebruary",
      "\n\n\nMarch",
      "\n\n\nApril",
      "\n\n\nMay",
      "\n\n\nJune",
      "\n\n\nJuly",
      "\n\n\nAugust",
      "\n\n\nSeptember",
      "\n\n\nOctober",
      "\n\n\nNovember",
      "\n\n\nDecember"
    };
  
  int determinedaycode(int year)
  {
    int d1, d2, d3;
    d1 = year/4.0;
    d2 = year/100.;
    d3 = year/400.;
    return 1 + (year + d1 + d2 + d3 + 1) % 7;
  }
  
  int determineleapyear(int year) 
  {
      return (year % 400 == 0) || ((year % 4 == 0) &amp;&amp; (year % 100 != 0));
  }
  
  void calendar(int year, int month, int daycode)
  {
      int day;
      printf("%s", months[month]);
      printf("\n\nSun  Mon  Tue  Wed  Thu  Fri  Sat\n");
  
        //Correct the position for the first date
        for (day = 1; day &lt;= 1 + daycode * 5; day++)
      {
        printf(" ");
      }
  
        //Print all the dates for one month
        for (day = 1; day &lt;= days_in_month[month]; day++)
      {
        printf("%2d", day);
  
        //Is day before Sat? Else start next line Sun.
        if ((day + daycode) % 7 &gt; 0)
          printf("   ");
        else
          printf("\n ");
      }
        // Set position for next month
        daycode = (daycode + days_in_month[month]) % 7;
  
        if (determineleapyear(year))
          days_in_month[2] = 29;
        printf("\n     %s %d\n", months[month], year);
  }
  
  //------------------------------------------
  int main() {
    int daycode, month, year;
  
     printf("\nEnter the month: ");
     scanf("%d", &amp;month);
     if (month &lt; 1 || month &gt; 12)
     {
          printf("Error: month must be in range 1..12");
          return printf("\nEnter the month: ");
          scanf("%d", &amp;month);
     }
  
     printf("\nEnter the year: ");
     scanf("%d", &amp;year);
     if (year &lt; 0)
     {
          printf("Error: year must be &gt; 0");
          return scanf("%d", &amp;year);
     }
  
     daycode = determinedaycode(year);
     calendar(year, month, daycode);
     printf("\n");
  
     return 0;
  }
  </code></pre>
  
  <p>Can anyone help me out with making it print just one month?</p>