Question: In C please Objective Use if() statement and integer division to determine if a given year is a leap year. Background Leap years normally occur
In C please
Objective Use if() statement and integer division to determine if a given year is a leap year. Background Leap years normally occur in every year that is a multiple of 4, e.g. the year 2020. There are exceptions, however: years that are a multiple of 100 are not leap years unless they are a multiple of 400. One algorithm is as follows (other algorithms are equally good): if (year is not divisible by 4) then it is a common year) else if (year is not divisible by 100) then it is a leap year) else if (year is not divisible by 400) then it is a common year) else (it is a leap year) Assignment 1. Write a function to determine if one integer is evenly divisible (i.e. a multiple of) another integer. The function should be declared as type int and return 1 if it is evenly divisible and O if it is not. 2. Using the function you wrote above, write another function to determine if a given year (passed in as an integer parameter) is a leap year or not. The function should be declared as type int and return 1 if the parameter is a leap year or O if the parameter is not a leap year. 3. In main(), test your functions by determining whether the following years were (or will be) leap years and print the results to the screen: 1776, 1860, 1900, 1943, 2000, 2076 Hint: Remember that integer division truncates the fractional part of the result if it is not evenly divisible. The following example illustrates this: 20/3 = 6 6*3 = 18 20-18 = 2 Divide one integer by the other integer. Multiplying the result by the divisor. Subtract that result from the dividend gives the remainder. If there is a remainder after dividing one integer (the dividend) by another integer (the divisor), then the dividend is not evenly divisible by the divisor. If the remainder is zero, then it is evenly divisible
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
