Module: Integer division and remainder


Problem

1 /16


Integer division and remainder

Theory Click to read/hide

In the module "Arithmetic expressions" we talked about the features of the division operation in Pascal.
Recall that for integer data (type integer) you can use three division operations:
- normal division, returns a value of type real
div - integer division, when we discard the fractional part as a result of the division operation
mod - calculation of the remainder of division

REMEMBER!

In Pascal the result of dividing an integer by an integer – it's always a real number.

Example: var a, b, d, e: integer;   c:real; a := 10; b := 3; c := a / b; // Answer: s = 3.33333333333333E+000 d := a mod b; // Answer: d = 1 e := a div b; // Answer: e = 3 These operations are very important in programming. They need to be understood and used correctly. And that takes practice!

 

Problem

Write a program that, given two numbers a and b, displays the result of integer division and the remainder, in the given format (see examples)

The input of the program is two numbers: a and b
You need to output two lines:
in the first line - the result of integer division of a by b
in the second line - the remainder of dividing a by b
See the output form in the example of input and output values

Example of input and output data
Input
15 6
Imprint
15 div 6 = 2
15 mod 6 = 3