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) → numThis operator-addition operator of int addition operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The number to be added to this integer. |
✐ Examples
1 Addition of 5 and 3
In this example,
- We assign the values
5and3to the integer variablesnum1andnum2respectively. - We perform the addition operation between
num1andnum2. - 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,
- We assign the values
-10and7to the integer variablesnum1andnum2respectively. - We perform the addition operation between
num1andnum2. - 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,
- We assign the values
20and-5to the integer variablesnum1andnum2respectively. - We perform the addition operation between
num1andnum2. - 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.