Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C please. Thank you.**Also don't have to do the extra credit, it's ok** Partial calendar program #include #include #include // for atoi void calmonth

In C please. Thank you.**Also don't have to do the extra credit, it's ok**

image text in transcribed

Partial calendar program

#include

#include

#include // for atoi

void calmonth (int, int); // output calendar for month given month and year

void calyear (int); // output calendar for year

int main (int argc, char* argv[])

{

int i, M=-1, Y=-1;

// process arguments no error checks implemented

for (i=1; i

{

if ((strcmp(argv[i],-m)==0) M=atoi(argv[i+1]);

if ((strcmp(argv[i],-y)==0) Y=atoi(argv[i+1]);

} If (Y==-1) {printf(Error, no year specified ); return 1; }

If (Y

If (M==-1) calyear(Y); else calmonth(M,Y);

return 0;

}

image text in transcribedimage text in transcribed

On the next page (also in the course notes on C) is a partial calendar program that enables a user to print the calendar for a particular month or an entire year. Year must be no earlier than 1752 (calendar reform) Complete the program by writing functions calmonth and calyear. You will probably need to figure out the day of the week on which a particular date falls. The following function implements Tomohiko Sakamoto's Day-Of-Week Algorithm andyields O for Sunday, 1 for Monday and so on int dow (int y, int m, int d) static int t] -0, 3, 2, 5, 0,3, 5, 1, 4, 6, 2, 4: return (y + y/4 y/100 + y/400 + t[m-1] + d) % 7; - You will also need to check if a particular year is a leap year. See section D of the course notes on C. Example program runs You do not need to format the months of a complete year side-by-side although extra credit if you do psmitheredwood: /comp162L/spring2019 mycalendar Error: no year specified psmith redwood:~/comp162L/spring2019$ mycalendar-m 7 Error no year specified psmith@redwood:~/comp162L/spring2019 mycalendar-y 1751 Error: year is earlier than 1752 psmith@redwood:~/comp162L/spring2019$ mycalendar -m 0 -y 1963 Error: month out of range psmitheredwood:~/comp162L/spring2019$ mycalendar-m 13-y 2000 Error: month out of range psmitheredwood: /comp162L/spring2019$ mycalendar-y 2019 -m 2 ruary 2019 3 4 5 6 7 89 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 psmith@redwood:~/comp162L/spring2019 mycalendar-m 2 -y 2019 February 2019 3 4 5 6789 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 psmith@redwood:~/comp162L/spring2019$ mycalendar -y 2020 January 2020 1 2 3 4 5 6 7 89 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 February 2020 S M T 2 3 45 6 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 lines omitted December 2020 SM TW TFS 678 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago