Menu

[Solved] C Programming Create Calendar Year 2019 Particular Month Highlight Particular Date Decembe Q37292815

  1. In C Programming create a calendar for the year 2019, for aparticular month highlight a particular date (December,25th) withan asterisk. Make sure the calendar displays the week, the days ofthe week and the year. Manipulate the following code:

#include<stdio.h>

#define TRUE    1

#define FALSE   0

int days_in_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

char *months[]=

{

            “”,

            “nnnJanuary”,

            “nnnFebruary”,

            “nnnMarch”,

            “nnnApril”,

            “nnnMay”,

            “nnnJune”,

            “nnnJuly”,

            “nnnAugust”,

            “nnnSeptember”,

            “nnnOctober”,

            “nnnNovember”,

            “nnnDecember”

};

int inputyear(void)

{

            intyear;

            printf(“Pleaseenter a year (example: 1999) : “);

            scanf(“%d”,&year);

            returnyear;

}

int determinedaycode(int year)

{

            intdaycode;

            intd1, d2, d3;

            d1= (year – 1.)/ 4.0;

            d2= (year – 1.)/ 100.;

            d3= (year – 1.)/ 400.;

            daycode= (year + d1 – d2 + d3) %7;

            returndaycode;

}

int determineleapyear(int year)

{

            if(year%4 == FALSE && year%100 != FALSE || year%400 == FALSE)

            {

                        days_in_month[2]= 29;

                        returnTRUE;

            }

            else

            {

                        days_in_month[2]= 28;

                        returnFALSE;

            }

}

void calendar(int year, int daycode)

{

            intmonth, day;

            for( month = 1; month <= 12; month++ )

            {

                        printf(“%s”,months[month]);

                        printf(“nnSun  MonTue  Wed  Thu Fri  Satn” );

                        //Correct the position for the first date

                        for( day = 1; day <= 1 + daycode * 5; day++ )

                        {

                                    printf(“”);

                        }

                        //Print all the dates for one month

                        for( day = 1; day <= days_in_month[month]; day++ )

                        {

                                    printf(“%2d”,day );

                                    //Is day before Sat? Else start next line Sun.

                                    if( ( day + daycode ) % 7 > 0 )

                                                printf(”   “);

                                    else

                                                printf(“n” );

                        }

                                    //Set position for next month

                    daycode = ( daycode + days_in_month[month] ) % 7;

            }

}

int main(void)

{

            intyear, daycode, leapyear;

            year= inputyear();

            daycode= determinedaycode(year);

            determineleapyear(year);

            calendar(year,daycode);

            printf(“n”);

}

Expert Answer


Answer to In C Programming create a calendar for the year 2019, for a particular month highlight a particular date (December,25th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *