Write a program that computes the rounded integer division between two integers, i.e. divide and round to the nearest integer. For the purposes of this exercise, this should be done without resorting to floats or doubles. Halfway cases, where the fractional part is exactly “.5”, should be rounded to the nearest even integer. Here are a few examples:
Each line of input will contain two integers n and d in the range:
-2 000 000 000 ≤ m, n ≤ 2 000 000 000
For each line of input your program should produce a line of output with the result of rounding m divided by n.
4 3 8 3 100 80 18 12
1 3 1 2
Your program should be implemented using an
that receives two integers as arguments and returns an integer.
Please refer to the information for the chosen language:
int roundiv(int n, int d);
roundiv :: Int -> Int -> Int
For the purposes of this exercise,
you should not use floats or doubles
nor rounding functions provided by your language of choice.
The point here is to exercise the implementation of rounding.
Submit your solution to be graded according to the following list:
try next: primes
Copyright © 2020-2021 Rudy Matela
All rights reserved