Dart int operator-division
Syntax & Examples
int.operator-division operator
The `/` operator in Dart performs division between this integer and another number.
Syntax of int.operator-division
The syntax of int.operator-division operator is:
operator /(num other) → doubleThis operator-division operator of int division operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The divisor. |
✐ Examples
1 Division of 10 by 3
In this example,
- We assign the values
10and3to the integer variablesnum1andnum2respectively. - We perform the division operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 10;
int num2 = 3;
double result = num1 / num2;
print('Result of division: $result');
}Output
Result of division: 3.3333333333333335
2 Division of 15 by 4
In this example,
- We assign the values
15and4to the integer variablesnum1andnum2respectively. - We perform the division operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 15;
int num2 = 4;
double result = num1 / num2;
print('Result of division: $result');
}Output
Result of division: 3.75
3 Division of 20 by -5
In this example,
- We assign the values
20and-5to the integer variablesnum1andnum2respectively. - We perform the division operation between
num1andnum2. - We print the result to standard output.
Dart Program
void main() {
int num1 = 20;
int num2 = -5;
double result = num1 / num2;
print('Result of division: $result');
}Output
Result of division: -4.0
Summary
In this Dart tutorial, we learned about operator-division operator of int: the syntax and few working examples with output and detailed explanation for each example.