Module: INTEGER DIVISION AND REMAIN


Problem

1 /16


Integer division and remainder

Theory Click to read/hide

In the Arithmetic Expressions module we talked about the features of the division operation in C#.
Recall that for integer data (type int) two division operations can be used.
/ - integer division, when the fractional part is discarded as a result of the division operation.
% - calculation of the remainder of the division.

Example:

int a, b;
a = 10;
b=3;
int c = a / b;   // Answer: c = 3
int d = a % b;    // Answer: d = 1


These operations are very important in programming. They need to be understood and used correctly.

 

Problem

Write a program that given two numbers a and b, displays the result of an integer division and the remainder, in the given format.

The program receives two numbers as input: a and b.
You need to output two lines:
in the first line - the result of integer division a by b.
in the second line - the remainder of dividing a by b.

Example.
Input Output
15
6
15/6=2
15%6=3