Module: (C++) Integer division and remainder


Problem

1 /16


Integer Devision and Remainer

Theory Click to read/hide

Integer Devision and Remainer


In the module "Arithmetic Expressions" we talked about the features of the division operation in tne C ++.
Recall, that for integer data (type int), you can use two division operations.
/ - integer division, when the fractional part is discarded as a result of the division operation
% - calculation of the remainder of the division]
 
Remember!

In the C and the C ++, the result of dividing an integer by an integer is always an integer, the remainder when dividing is discarded.

 
Example
#include<iostream>
using namespace std;
int main()
{
  int a, b;
  a = 10;
  b = 3;
  int c = a / b;   // с = 3
  int d = a% b;    // d = 1
  cout << c << " " << d << endl;
  return 0;
}

These operations are very important in programming. They need to be understood and used correctly.
And this requires practice!

Problem

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

Input format
a and b are inputs in the line.

Output format
In the first line, output the result of integer division a and b.
in the second line, outputs remainder of the division a on b.
Format of output is given in example.
 
Example
N Input Output
1 15 6 15/6=2
15%6=3