Question: C Programming Create a calendar that allows the user to print a calendar for a month or entire year. Modify calmonth(), calyear(), and main(). Be

C Programming

Create a calendar that allows the user to print a calendar for a month or entire year.

Modify calmonth(), calyear(), and main().

Be Aware of:

  • Leap years.
  • Invalid months from user input.
  • Invalid years from user input.
  • You'll have to modify the main() method a bit.

Leap Year Algorithm

It is a leap year if divisible by 4, except for years divisible by 100. But, if the year is divisible by 400, it is a leap year.

Code:

#include  #include  #include  // y > 1752, 1 >= m >= 12 int dow(int y, int m, int d) { static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; y -= m  
 Expected Output:

C Programming Create a calendar that allows the user to print a

Aprii 2019 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 $ ./mycal -y 2019 January 2019 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 February 2019 3 4 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 March 2019 S M T W T F S 3 4 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Aprii 2019 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 $ ./mycal -y 2019 January 2019 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 February 2019 3 4 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 March 2019 S M T W T F S 3 4 5 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!