Question: lab4C.c #include int main(){ char input[30]; int i; int dates; int day, year, month; printf(Enter 'month-day year' : ); fgets(input, 30, stdin); /* read

 lab4C.c #include int main(){ char input[30]; int i; int dates; int

day, year, month; printf("Enter 'month-day year' : " ); fgets(input, 30, stdin);

lab4C.c

#include  int main(){ char input[30]; int i; int dates; int day, year, month; printf("Enter 'month-day year' : " ); fgets(input, 30, stdin); /* read in the whole line */ while ( ) { /* manipulate the input, count days and display */ // read again printf("Enter 'month-day year': " ); fgets(input, 30, stdin); /* read in the whole line */ } return 0; } int countDays(int y, int m, int d){ } 

3. Problem C String Library functions, operators, multiple files 3.1 Specification Write an ANSI-C program that reads input from the standard input about date, and then calculate the number days that has elapsed in the year The program keeps on prompting user to enter Month-Date Year (three words separated by a dash and a space). For each input your program displays the days that have elapsed from the start of the year. Program terminates when user enters quit 3.2 Implementation Download file lab4C.c and start from there. The program uses fgets) to read in a whole line. Don't modify the existing codes. Implement the function int countDays (int year, int month, int day) which calculates how many days have elapsed since the start of the year. For simplicity, assume that there are 31 days in Jan, Mar, May, July, Sep and Nov, and there are 30 days in April, une, Aug, Oct and Dec. There are 29 days in Feb if the year is a leap year, and 28 days in Feb if the year is not leap year. a Define function isLeap (int year) as you did for lab 2. Put the definition of this function in another file named leap.c. Implement the while conditions, checking if input is quit. Display the output as xx days of year xxx have elapsed . How to get year, month and date information from the line of string? That is, how to tokenize a string? How about sscanf mentioned in class? . In implementing countDays,instead of checking month with lots if... elseif.. elseif elseif Or if (11 11 1.11 11 ), can you use an arithmetic operator to simplify the code? When fgets reads in a line, it appends a new line character at the end (before \0). For . example, input a line is stored as'a''' '1''' 'n''e' ''0 where are some other values(0'or random values). Be careful when checking if the input is quit You should not put #include "leap. c" in your main program in order to use isLeap() function. The proper way is to declare the function and compile the programs together 3.3 Sample Inputs/Outputs: (ONE blank link between each interaction/iteration) red 339 % a.out Enter 'month-date year 1-1 2010 1 days of year 2010 have elapsed Enter 'month-date year 8-8 2011 220 days of year 2011 have elapsed Enter 'month-date year 8-8 2012 221 days of year 2012 have elapsed Enter 'month-date year 8-8 2016 221 days of year 2016 have elapsed Enter 'month-date year 10-1 2010 274 days of year 2010 have elapsed Enter 'month-date year 10-1 2012 275 days of year 2012 have elapsed Enter 'month-date year 5-4 2017 124 days of year 2017 have elapsed Enter 'month-date year' 5-4 2012 125 days of year 2012 have elapsed

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!