can you add some event in this program like 14 aug ,eid,christmas etc, Step 1 Program Plan:- Initialize all the required header files. Initialize a global array for the the days of all months  also define the function to know whether the given year is leap year or not.  if the year is leap update the days of feb to 29 .  Define the function for finding the dayCode.  Finally print the calender of the given year. Step 2 The following is the required C program for Calender Application- #include #define TRUE    1 #define FALSE   0 int daysOfMonths[]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; char *Months[]= {     " ",     "\n\n\nJanuary",     "\n\n\nFebruary",     "\n\n\nMarch",     "\n\n\nApril",     "\n\n\nMay",     "\n\n\nJune",     "\n\n\nJuly",     "\n\n\nAugust",     "\n\n\nSeptember",     "\n\n\nOctober",     "\n\n\nNovember",     "\n\n\nDecember" }; int Year(void) {     int year;     printf("Please enter a year (example: 1999) : ");     scanf("%d", &year);     return year; } int dayCode(int year) {     int daycode;     int d1, d2, d3;     d1 = (year - 1.)/ 4.0;     d2 = (year - 1.)/ 100.;     d3 = (year - 1.)/ 400.;     daycode = (year + d1 - d2 + d3) %7;     return daycode; } int IsLeapYear(int year) {     if(year% 4 == FALSE && year%100 != FALSE || year%400 == FALSE)     {         daysOfMonths[2] = 29;         return TRUE;     }     else     {         daysOfMonths[2] = 28;         return FALSE;     } } void calendar(int year, int daycode) {     int month, day;     for ( month = 1; month <= 12; month++ )     {         printf("%s", Months[month]);         printf("\n\nSun  Mon  Tue  Wed  Thu  Fri  Sat\n" );         //finding 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 <= daysOfMonths[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 + daysOfMonths[month] ) % 7;     } } int main(void) {     int year, daycode, leapyear;     year = Year();     daycode = dayCode(year);     IsLeapYear(year);     calendar(year, daycode);     printf("\n"); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

can you add some event in this program like 14 aug ,eid,christmas etc,

Step 1

Program Plan:-

  1. Initialize all the required header files.
  2. Initialize a global array for the the days of all months 
  3. also define the function to know whether the given year is leap year or not. 
  4. if the year is leap update the days of feb to 29 . 
  5. Define the function for finding the dayCode. 
  6. Finally print the calender of the given year.

Step 2

The following is the required C program for Calender Application-

#include<stdio.h>

#define TRUE    1
#define FALSE   0

int daysOfMonths[]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
char *Months[]=
{
    " ",
    "\n\n\nJanuary",
    "\n\n\nFebruary",
    "\n\n\nMarch",
    "\n\n\nApril",
    "\n\n\nMay",
    "\n\n\nJune",
    "\n\n\nJuly",
    "\n\n\nAugust",
    "\n\n\nSeptember",
    "\n\n\nOctober",
    "\n\n\nNovember",
    "\n\n\nDecember"
};


int Year(void)
{
    int year;

    printf("Please enter a year (example: 1999) : ");
    scanf("%d", &year);
    return year;
}

int dayCode(int year)
{
    int daycode;
    int d1, d2, d3;

    d1 = (year - 1.)/ 4.0;
    d2 = (year - 1.)/ 100.;
    d3 = (year - 1.)/ 400.;
    daycode = (year + d1 - d2 + d3) %7;
    return daycode;
}


int IsLeapYear(int year)
{
    if(year% 4 == FALSE && year%100 != FALSE || year%400 == FALSE)
    {
        daysOfMonths[2] = 29;
        return TRUE;
    }
    else
    {
        daysOfMonths[2] = 28;
        return FALSE;
    }
}

void calendar(int year, int daycode)
{
    int month, day;
    for ( month = 1; month <= 12; month++ )
    {
        printf("%s", Months[month]);
        printf("\n\nSun  Mon  Tue  Wed  Thu  Fri  Sat\n" );

        //finding 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 <= daysOfMonths[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 + daysOfMonths[month] ) % 7;
    }
}

int main(void)
{
    int year, daycode, leapyear;

    year = Year();
    daycode = dayCode(year);
    IsLeapYear(year);
    calendar(year, daycode);
    printf("\n");
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education