Question: The code provided is: /** * This program determines if various years are leap * years or not. * */ #include #include /** * Returns

 The code provided is: /** * This program determines if various

The code provided is:

/** * This program determines if various years are leap * years or not. * */ #include  #include  /** * Returns true (1) if the given year is a leap year, * false (0) if it is not a leap year. */ int isLeapYear(int year); int main(int argc, char **argv) { int year; int numPassed = 0; int numFailed = 0; //Hard-coded ad-hoc test cases //Do not change these, add your own test cases //below. All test cases should pass. year = 2000; printf("Test Case 1: year = %d: ", year); if(!isLeapYear(year)) { printf("FAILED! "); numFailed = numFailed + 1; } else { printf("PASSED! "); numPassed = numPassed + 1; } year = 2001; printf("Test Case 2: year = %d: ", year); if(isLeapYear(year)) { printf("FAILED! "); numFailed = numFailed + 1; } else { printf("PASSED! "); numPassed = numPassed + 1; } year = 2100; printf("Test Case 3: year = %d: ", year); if(isLeapYear(year)) { printf("FAILED! "); numFailed = numFailed + 1; } else { printf("PASSED! "); numPassed = numPassed + 1; } //TODO: write at least 3 more of your own // test cases here, they should all pass! printf(" "); printf("Summary: "); printf("Number of test cases passed: %d ", numPassed); printf("Number of test cases failed: %d ", numFailed); printf("Percentage Passed: %.2f%% ", (double) numPassed / (numPassed + numFailed) * 100.0); return 0; } int isLeapYear(int year) { //TODO: Write your logic here // The year is stored in the variable year // Your function should return true (1) if it represents a leap year // and false (0) if it does not. }

Leap Years Nearly every 4 years is a leap year in the Gregorian calendar. In a leap year, there are 366 days (adding February 29th) instead of the usual 365. A year is a leap year if it is divisible by 4. However, every year that is divisible by 100 is not a leap year unless it is divisible by 400. 2000, 2004, 2008 were leaps years but 2001, 2002, 2003 were not. 1900 was not a leap year; though it was divisible by 4 it was divisible by 100 but not 400 . We've provided a partially completed program, leapYear.c that tests whether or not various years are leap years. 1. Implement a conditional statement inside the isLeapYear() function to determine if the given year is a leap year or not. Return true (1) if it is, false (0) if it is not. 2. Compile and run your program: we've provided 3 hard-coded test cases. Fix any errors in your program until they all pass. 3. Using the provided code as an example, add at least 3 more test cases to your program. Repeat your compile/run/test until they all pass

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!