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!