Homework assignment #4

Due Wednesday, December 1

Write a program to read a date as 3 numbers from the keyboard, and print out the corresponding text date (such as "November 19, 1999").

You should already know how to read a single number from the keyboard using scanf. You may either use 3 scanf calls to read 3 numbers, or the following will work:

    scanf ("%d %d %d", &month, &day, &year);

assuming, of course, that you have int variables named month, day, and year.

The numbers should be entered in the order shown above, and the output should be one of the following:

  1. If the numbers describe a valid date, print the date using the month name, the day number, a comma, and the year.
  2. If the numbers do not describe a valid date, print: "Invalid date!" A date is invalid if the day number is less than 1, or if it is larger than the maximum for that month. You can look up the lengths of each month if you don't already know. Don't worry about leap years yet; you may assume that February is always 28 days.

I want you to turn in your code in a file named date1.c. You may use this Visual Studio project file if you like:
Date1.zip