Write a function in C programming not C++: int days_in_month(int month, int year
ID: 3686763 • Letter: W
Question
Write a function in C programming not C++: int days_in_month(int month, int year);
which is given a month and year and returns the number of days in that month. You should use your is_leap() function as needed to determine the number of days in the month (February has an extra day in leap years). Put the code for the function days_in_month() in the file days.c, and the prototype in the file days.h
Write a driver, main(), to ask the user to enter the month and year (use EOF to terminate the program) and prints the number of days. Put the driver in the file driver2.c. You will compile this program with the command: make driver2
which will compile and link the source files days.c leap.c and driver2.c to create an executable called driver2.
I also need help creating a days.c file and days.h file
Explanation / Answer
#include<conio.h>
#include<stdio.h>
void main()
{
int year,month;
clrscr();
printf("Enter year:=");
scanf("%d",&year);
printf("Enter month:=");
scanf("%d",&month);
is_leap(year);
days_in_month(year, month);
}
void is_leap(int year)
{
if((year%400==0)||((year%100!=0)&&(year%4==0)))
{
printf("%d :: is a leap year with 366 days ",year);
}else
{
printf("%d :: with 365 days ",year);
}
void days_in_month(int year, int month)
{
if(month==1)
{
printf("January Days: 31");
}
else if(month==2)
{
printf("February Days: 29");
}
else if(month==3)
{
printf("March Days: 31");
}
else if(month==4)
{
printf("April Days: 30");
}
else if(month==5)
{
printf("May Days: 31");
}
else if(month==6)
{
printf("June Days: 30");
}
else if(month==7)
{
printf("July Days: 31");
}
else if(month==8)
{
printf("August Days: 31");
}
else if(month==9)
{
printf("September Days: 30");
}
else if(month==10)
{
printf("October Days: 31");
}
else if(month==11)
{
printf("November Days: 30");
}
else if(month==12)
{
printf("December Days: 31");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.