Code:
#include <stdio.h>
int main()
{
/* declare ints */
int sday; int smonth; int syear; int eday; int emonth;
int eyear; int y; int m; int d; int bmonth; int byear;
/* declare array */
int myCal[13][2];
/* create calender */
myCal[0][0] = 0; myCal[1][0] = 1; myCal[2][0] = 2; myCal[3][0] = 3;
myCal[4][0] = 4; myCal[5][0] = 5; myCal[6][0] = 6; myCal[7][0] = 7;
myCal[8][0] = 8; myCal[9][0] = 8; myCal[10][0] = 10; myCal[11][0] = 11;
myCal[12][0] = 12;
myCal[0][1] = 0; myCal[1][1] = 31; myCal[2][1] = 28; myCal[3][1] = 31;
myCal[4][1] = 30; myCal[5][1] = 31; myCal[6][1] = 30; myCal[7][1] = 31;
myCal[8][1] = 31; myCal[9][1] = 30; myCal[10][1] = 31; myCal[11][1] = 30;
myCal[12][1] = 31;
/* open external file */
/* get nessesary inputs */
printf ("Enter the starting day\n");
scanf ("%d", &sday);
printf ("Enter the starting month\n");
scanf ("%d", &smonth);
printf ("Enter the starting year\n");
scanf ("%d", &syear);
printf ("Enter the ending day\n");
scanf ("%d", &eday);
printf ("Enter the ending month\n");
scanf ("%d", &emonth);
printf ("Enter the ending year\n");
scanf ("%d", &eyear);
/* starting dates and ending dates are not in the same year */
if (eyear != syear)
{
/* crunching everything from start to a year before end year */
byear = eyear - 1;
for (y = syear; y <= byear; y++)
{
if (y%4 == 0)
{
myCal[2][1] = 29;
for (m = smonth; m <= 12; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
}
else if (y%4 > 0)
{
myCal[2][1] = 28;
for (m = smonth; m <= 12; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
}
}
/* crunch everything on the ending year with byear = syear */
if (byear == syear)
{
if (y%4 == 0)
{
/* calculates every month before ending month */
myCal[2][1] = 29;
bmonth = emonth -1;
for (m=smonth; m<=bmonth; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
/* now calculates the final month */
if (emonth > 0)
{
for (d=1;d<=eday;d++)
{
printf ("%d/%d/%d \n", emonth, d, y);
}
}
}
else if (y%4 > 0)
{
/* calculates every month before ending month */
myCal[2][1] = 28;
bmonth = emonth -1;
for (m=smonth; m<=bmonth; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
/* now calculates the final month */
if (emonth > 0)
{
for (d=1;d<=eday;d++)
{
printf ("%d/%d/%d \n", emonth, d, y);
}
}
}
}
/* crunch everything on the ending year with byear not equal to syear */
else if (byear != syear)
{
if (y%4 == 0)
{
myCal[2][1] = 29;
bmonth = emonth -1;
for (m=smonth; m<=bmonth; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
/* now calculates the final month */
if (emonth > 0)
{
for (d=1;d<=eday;d++)
{
printf ("%d/%d/%d \n", emonth, d, y);
}
}
}
else if (y%4 > 0)
{
/* calculates every month before ending month */
myCal[2][1] = 28;
bmonth = emonth -1;
for (m=smonth; m<=bmonth; m++)
{
for (d = sday; d<= myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, y);
}
}
/* now calculates the final month */
if (emonth > 0)
{
for (d=1;d<=eday;d++)
{
printf ("%d/%d/%d \n", emonth, d, y);
}
}
}
}
}
/* starting dates and ending dates ARE in the same year */
else if (syear = eyear)
{
if (y%4 == 0)
{
myCal[2][1]=29;
bmonth = emonth - 1;
for (m=smonth;m<=bmonth;m++)
{
for (d=sday; d<=myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, syear);
}
}
if (emonth > 0)
{
for (d=sday; d<=eday; d++)
{
printf ("%d/%d/%d \n", emonth, d, syear);
}
}
}
else if (y%4 > 0)
{
myCal[m][1]=28;
bmonth = emonth -1;
for (m=smonth;m<=bmonth;m++)
{
for (d=sday; d<=myCal[m][1]; d++)
{
printf ("%d/%d/%d \n", m, d, syear);
}
}
}
}
return 0;
}