Dart int operator-modulo
Syntax & Examples


int.operator-modulo operator

The `%` operator in Dart performs the Euclidean modulo operation.


Syntax of int.operator-modulo

The syntax of int.operator-modulo operator is:

operator %(num other) → num

This operator-modulo operator of int euclidean modulo operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe divisor.


✐ Examples

1 Euclidean modulo operation with 10 and 3

In this example,

  1. We assign the values 10 and 3 to the integer variables num1 and num2 respectively.
  2. We perform the Euclidean modulo operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 10;
  int num2 = 3;
  int result = num1 % num2;
  print('Result of Euclidean modulo operation: $result');
}

Output

Result of Euclidean modulo operation: 1

2 Euclidean modulo operation with 15 and 4

In this example,

  1. We assign the values 15 and 4 to the integer variables num1 and num2 respectively.
  2. We perform the Euclidean modulo operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 15;
  int num2 = 4;
  int result = num1 % num2;
  print('Result of Euclidean modulo operation: $result');
}

Output

Result of Euclidean modulo operation: 3

3 Euclidean modulo operation with 20 and 7

In this example,

  1. We assign the values 20 and 7 to the integer variables num1 and num2 respectively.
  2. We perform the Euclidean modulo operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 20;
  int num2 = 7;
  int result = num1 % num2;
  print('Result of Euclidean modulo operation: $result');
}

Output

Result of Euclidean modulo operation: 6

Summary

In this Dart tutorial, we learned about operator-modulo operator of int: the syntax and few working examples with output and detailed explanation for each example.