Modulo: %, mod

Using the modulo operator we can calculate the remainder after integer division. by using the modulo operator we can easily test the divisibility of integers, if the result is 0, then the number is divisible without a remainder.

%

Description

par1 % par2
Used keywords: %

Input


Output

Compatible programing languages:
C | Visual C++ .NET | C++ | C# | Java | JavaScript | PHP

Examples

Example

Modulo the possible of use:
x = 90 % 8;    // x = 2
y = 15 % 4;    // y = 3
z = (x % y) %5;// z = 2

Example

Even one example in what situations we can use the operation modulo:
i % 4
121 % 40
(0xff % 50 % 10) % 2

Example

Other pieces of example codes:
(15 % 4)
(1500 % 60)
70 % 8
 y = 15 % 4
 y = 1025 % 8

mod

Description

par1 mod par2
Used keywords: mod

Input


Output

Compatible programing languages:
Basic | Visual Basic .NET | FreeBASIC | Free Pascal | Object Pascal | Pascal

Examples

Basic

Modulo the possible of use:
x = 90 mod 8    ' x = 2
y = 15 mod 4    ' y = 3
z = (x mod y) mod 5' z = 2

Basic

Even one example in what situations we can use the operation modulo:
i mod 4
121 mod 40
(&Hff mod 50 mod 10) mod 2

Basic

Other pieces of example codes:
70 mod 8
(1500 mod 60)

You can find it in the following collections: arithmetic operators
Languages: en hu cz sk