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"); }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 6PP: (Numerical) a. Define an array with a maximum of 20 integer values, and fill the array with numbers...
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,