title: Write a program in C that prompts the user to enter two dates and then indicates which date comes earlier on the calender
body: <p>My code is as follow:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(void)
  {
      int m1, m2, d1, d2, y1, y2;
  
      printf("enter first date (mm/dd/yy): ");
      scanf("%d/%d/%d", &amp;m1, &amp;d1, &amp;y1);
  
      printf("enter second date (mm/dd/yy): ");
      scanf("%d/%d/%d", &amp;m2, &amp;d2, &amp;y2);
  
      if (y1&lt;y2)
          printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
      else
          printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);
  
      if (y1==y2)
      {if (m1&lt;m2)
              printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
      else if (m2&lt;m1)
          printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);}
  
      if (y1==y2 &amp;&amp; m1==m2)
      {if (d1&lt;d2)
          printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m1, d1, y1, m2, d2, y2);
      else
          printf("%d/%d/%.2d is earlier than %d/%d/%.2d\n",m2, d2, y2, m1, d1, y1);}
  
      return 0;
  
  }
  </code></pre>
  
  <p>Im trying to keep it simple since I am a beginner and am only on chapter 5 in King's C Programming Modern Approach Textbook. When I enter the following: </p>
  
  <p>enter first date (mm/dd/yy): 03/31/93
  enter second date (mm/dd/yy): 04/31/93</p>
  
  <p>the response i get is:</p>
  
  <p>4/31/93 is earlier than 3/31/93 AND
  3/31/93 is earlier than 4/31/93</p>
  
  <p>Any help is much appreciated. Thanks.</p>