Dart int operator-addition
Syntax & Examples


int.operator-addition operator

The `+` operator in Dart performs addition between this integer and another number.


Syntax of int.operator-addition

The syntax of int.operator-addition operator is:

operator +(num other) → num

This operator-addition operator of int addition operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe number to be added to this integer.


✐ Examples

1 Addition of 5 and 3

In this example,

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

Dart Program

void main() {
  int num1 = 5;
  int num2 = 3;
  int result = num1 + num2;
  print('Result of addition: $result');
}

Output

Result of addition: 8

2 Addition of -10 and 7

In this example,

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

Dart Program

void main() {
  int num1 = -10;
  int num2 = 7;
  int result = num1 + num2;
  print('Result of addition: $result');
}

Output

Result of addition: -3

3 Addition of 20 and -5

In this example,

  1. We assign the values 20 and -5 to the integer variables num1 and num2 respectively.
  2. We perform the addition operation between num1 and num2.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 20;
  int num2 = -5;
  int result = num1 + num2;
  print('Result of addition: $result');
}

Output

Result of addition: 15

Summary

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