Note about error checking: Starting with this assignment, I do want you to do at least minimal checking that input from standard input is sensible. As mentioned in class, doing a really great job of parsing and validating input is not especially easy, but for our purposes it's enough to check that scanf was able to get value(s) of the requested type(s) and that the values meet whatever other criteria the problem states (e.g., not negative for the second problem).
Solution: Here are two solutions, first the one beginners are most likely to write and then one that adapts ideas from more general sorts to use for this particular limited case.
Refer to assignment for description of problem.
Solution: Here is one solution: