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) → numThis operator-modulo operator of int euclidean modulo operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The divisor. |
✐ Examples
1 Euclidean modulo operation with 10 and 3
In this example,
- We assign the values
10and3to the integer variablesnum1andnum2respectively. - We perform the Euclidean modulo operation between
num1andnum2. - 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,
- We assign the values
15and4to the integer variablesnum1andnum2respectively. - We perform the Euclidean modulo operation between
num1andnum2. - 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,
- We assign the values
20and7to the integer variablesnum1andnum2respectively. - We perform the Euclidean modulo operation between
num1andnum2. - 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.