Homework Assignment 3 Solutions

Solutions:
  1. Write a program which inputs two integers and prints the larger of the two.
    Solution

  2. Write a program which inputs three integers and prints the middle value of the two.
    Solution

  3. 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 such so that (i*d) < n <= (j*d) and print (i*d) and (j*d).
    Solution

  4. Write a program that accepts four integers, i, j, k, n and prints which of the relations is correct: i/j < k/n, or i/j == k/n, or i/j > k/n For this problem, do not use floating point arithmetic. You should determine the equality or inequality using only integer arithmetic.
    Solution