Question: Task: Write a program to find the difference between two dates. The start date and end date are entered as integers giving the day, month,

Task: Write a program to find the difference between two dates. The start date and end date are entered as integers giving the day, month, and year (the full year (e.g. 2016), since dates can be in any century). For example, the due date for this assignment is 7 3 2016 (how many days until it is due?) In this bottom-up implementation approach, we will begin by implementing simple functions, then use these functions to implement more complicated functions until we can solve the entire task. At each step, we will write a driver program as main() to test the function we are adding. You should test your function thoroughly at each step to ensure that it works correctly for appropriate data.

Do Problem 6 in Section 3.9 of the text.

Write a program that uses a function to determine if a given year is a leap year A year is a leap year if it is divisible by or if it is divisible by and it is not divisible by 100

This problem asks for a function: int is_leap(int year); which when given a year (> 0), determines if the year is a leap year, returning TRUE or FALSE. You should put the code for this function in the file leap.c and the prototype for the function in the file leap.h. Write a main() which repeatedly asks the user to enter a year and prints if it is a leap year or not. The program terminates when the user enters 0 for the year. Put the code for the driver in the file driver1.c. You will compile this program with the command: make driver1 which will create an executable called driver1. 2. Days in a Month

Sub-Task: Write a function: 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. 3.

Sub-Task: Write a function: int julian_date(int day, int month, int year); This function is given the day, month and year and returns the Julian date. The Julian date is the ordinal day number for that day. For example, 1 Jan is day 1 of any year, 31 Dec is day 365 for any non-leap year and 1 Feb is day 32 for any year. Use your days_in_month() function from the previous problem to calculate the Julian date. Put the code for the function julian_date() in the file julian.c, and the prototype in the file julian.h Write a driver, main(), which asks the user to enter a month, day, year and prints the Julian date. Terminate with EOF. Put the driver in the file driver3.c. You will compile this program with the command: make driver3 which will create an executable called driver3. 4.

Date Difference To complete the overall task, you need to write just one more driver using the functions you have written so far. The driver is to read a start date and end date and compute the number of days between them. Terminate the program when EOF occurs when reading the start date. You should think about your algorithm for this program in terms of what "tools" you have to use (the functions written in the previous three problems). Implement your algorithm in main() in the file datediff.c. You will compile this program with the command: make datediff which will create an executable called datediff.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!