The compiler converts the source file (

Command:

You should use these options (in any order)

`-Wall`produce all types of warning messages. Your code should compile with no warnings (certainly without any warnings that you are absolutely sure don't matter).`-O`optimize. In the process, will warn about uninitialized variables. If your reason is to optimize, look up different variants.`-std=c11`Use the latest standard (2011). Useful e.g. for local declarations in`for`. For older compilers, use`-std=c99`.`-lm`Compile with the math library. Needed when you use functions from`math.h``-o`*execfile*Use if you don't want the default name`a.out`for the generated executable.

where

write a function that does the stated task, returning the appropriate result

in

1. **Leap year** Write a function that determines if a year is a leap year (returns 1 if true, 0 otherwise). The rules are:

- A year divisible by 4 is a leap year.
- As an exception to 1), years divisible by 100 are not leap years
- As an exception to 2), years divisible by 400 are leap years.

Write a function that tests your implementation by comparing the result with that given by the standard function

3. **Median of three** Write a function that returns the median of three numbers (i.e., the
middle one, when ordering the numbers by value).

Use conditional expressions. Avoid long and complex code.
Test your code for all possible orderings of the arguments (how many?)

Option 1: if you first compare two numbers, you are left with a similar
problem but with extra information: the ordering between two of the numbers.
Write a function to solve this subproblem, and call it in the function
that you were asked to write.

Option 2: can you write the function just by composing *max* and *min* of pairs of values? Hint: the values should appear symmetrically.

Which version makes the smallest number of comparisons in the worst case?

4. **Distinct values** Write a function that takes three integers, returns the number of distinct values among these (1, 2 or 3) and prints, depending on the case, "all arguments are equal / distinct", or "arguments 1 and 2 / 2 and 3 / 1 and 3 are equal".

Use as little duplicate code as possible, writing helper functions where useful.

5. **Bonus value** A local public transit ride in NYC is $2.75. You can load up your MetroCard with any multiple of 5 cents. If you load up with at least the value of two trips, you get a 5% bonus, rounded to a cent. Write a function that computes and returns the amount you need to load for N trips, and also prints the amount that will be left on the card. You can check your results here .