Read:
Program:
Write and debug the following four programs. The names of the
programs are given. Use the
PostIt script
to submit your work.
LargerOfTwo.C
:
Write a program which inputs two integers and prints
the larger of the two.
MiddleOfThree.C
:
Write a program which inputs three integers and prints
the middle value among the three.
NearestMultiple.C
:
Write a program which inputs two integers and prints the largest
multiple of the second which is smaller than the first, and the smallest
multiple of the second which as at least as large as the first.
That is, input n and d, then find i and j=i+1 such so that
and print (i*d) and (j*d).
What conditions on n and d are necessary for this problem to be solvable? For extra credit, use if statements to prevent bad inputs.
CompareFractions.C
:
Write a program that accepts four integers, i, j, k, n and
prints which of the relations is correct:
For this problem, do not use floating point arithmetic. You should
determine the equality or inequality using only integer arithmetic.
Do this problem in 2 steps: