There are some errors, and need help fixing them. Write a program that prompts t
ID: 3531814 • Letter: T
Question
There are some errors, and need help fixing them.
Write a program that prompts the user to enter the year and first day of the year and displays on the console the calendar table for the year. For example, if the user entered year 2005, and 6 for Saturday, January 1, 2005, your program should display the calendar for each month in the year.
#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 [] =
{
" ",
" January",
" February",
" March",
" April",
" May",
" June",
" July",
" August",
" September",
" October",
" November",
" December",
};
int inputyear (void)
{
int year;
printf("Please enter a year (example: 1999): ");
scanf("%d", &year);
return year;
}
int daycode, year;
int d1, d2, d3;
{
d1 = (year - 1.)/ 4.0;
d2 = (year - 1.)/ 100.;
d3 = (year - 1.)/ 400.;
daycode = (year + d1 - d2 + d3) %7;
?
?
scanf("%d", &daycode, &year);
}
return daycode;
?
?
int determineleapyear (int year)
{
if(year% 4 == false && year != false || year == false)
{
days_in_month[2] = 29;
return true;
}
else
{
days_in_month[2] = 28;
return false;
}
}
void calender(int year, int daycode)
{
int month, day;
for (month = 1; month <= 12; month++)
{
printf("%s", months[month]);
printf(" Sun Mon Tue Wed Thu Fri Sat ");
for (day = 1; day <= 1 + daycode *5; day++)
{
printf(" ");
}
for (day = 1; day <= days_in_month[month]; day++)
{
printf("-", day);
if ((day + daycode) % 7 > 0)
printf(" ");
else
printf(" ");
}
daycode = (daycode + days_in_month[month]) % 7;
}
}
int main (void)
{
int year, daycode, leapyear;
year = inputyear ();
daycode = determinedaycode(year);
determineleapyear (year);
calendar (year, daycode);
printf(" ");
}
Explanation / Answer
just by glancing at it, you are missing your string library (string.h)
When do you need this by?
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.