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) → double

This operator-division operator of int division operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe divisor.


✐ Examples

1 Division of 10 by 3

In this example,

  1. We assign the values 10 and 3 to the integer variables num1 and num2 respectively.
  2. We perform the division operation between num1 and num2.
  3. 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,

  1. We assign the values 15 and 4 to the integer variables num1 and num2 respectively.
  2. We perform the division operation between num1 and num2.
  3. 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,

  1. We assign the values 20 and -5 to the integer variables num1 and num2 respectively.
  2. We perform the division operation between num1 and num2.
  3. 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.