title: Gregorian Calendar in C
body: <p>I really don't know much about c program so really need your help.. 
  This is the program to find the day of input value(ex. 1583.3.31 -> Thursday) and print "Wrong year/month/day" if it is unvalid date.
  I wrote return 0; in the middle part because I have to get out from this when the date is unvalid. I checked it works. But eventhough when the date is valid (ex. 1583.3.31) it doesn't go to the next part(should print day if number is valid) It just ends the program. I wonder why:(</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
  int year, month, day;
  
  printf("Enter Gregorian year (year &gt;= 1583): ");
  scanf("%d", &amp;year);
  
  printf("Enter Gregorian month (month: 1..12): ");
  scanf("%d", &amp;month);
  
  printf("Enter Gregorian day (1..28|29|30|31): ");
  scanf("%d", &amp;day);
  
  {if (month &lt; 1 || month &gt; 12)
      printf("Wrong month! Try again!");
  if (year &lt; 1583)
      printf("Enter year &gt;= 1583! Try again!");
  if (day &lt; 1 || day &gt; 31)
              printf("Wrong day! Try again!");
  if (month == 4 &amp;&amp; (day &lt; 1 || day &gt; 30))
          printf("Wrong day! Try again!");
  if (month == 6 &amp;&amp; (day &lt; 1 || day &gt; 30))
          printf("Wrong day! Try again!");
  if (month == 9 &amp;&amp; (day &lt; 1 || day &gt; 30))
          printf("Wrong day! Try again!");
  if (month == 11 &amp;&amp; (day &lt; 1 || day &gt; 30))
          printf("Wrong day! Try again!");
  if (month == 2){
      if (year % 4 == 0 &amp;&amp; (day &lt; 1 || day &gt; 29))
          printf("Wrong day! Try again!");
      if (year % 100 == 0 &amp;&amp; (day &lt; 1 || day &gt; 28))
          printf("Wrong day! Try again!");
      if (year % 400 == 0 &amp;&amp; (day &lt; 1 || day &gt; 29))
          printf("Wrong day! Try again!");}
  else if (month == 2 &amp;&amp; (day &lt; 1 || day &gt; 28))
          printf("Wrong day! Try again!");
  return 0;}
  
  year += 8000;
  
  if (month &lt; 3) { year--; month += 12; }
  
  long julian = (year*365) + (year/4) - (year/100) + (year/400) - 1200820 + (month*153+3)/5 - 92 + (day-1);
  
  switch(julian % 7){
      case 0:
          printf("%d-%d-%d is Monday", year -= 8000, month, day);
          break;
      case 1:
          printf("%d-%d-%d is Tuesday", year -= 8000, month, day);
          break;
      case 2:
          printf("%d-%d-%d is Wednesday", year -= 8000, month, day);
          break;
      case 3:
          printf("%d-%d-%d is Thursday", year -= 8000, month, day);
          break;
      case 4:
          printf("%d-%d-%d is Friday", year -= 8000, month, day);
          break;
      case 5:
          printf("%d-%d-%d is Saturday", year -= 8000, month, day);
          break;
      case 6:
          printf("%d-%d-%d is Sunday", year -= 8000, month, day);
          break;}
  return 0;
  }
  </code></pre>