Dart int operator-multiplication
Syntax & Examples
int.operator-multiplication operator
The `*` operator in Dart performs multiplication between two numbers.
Syntax of int.operator-multiplication
The syntax of int.operator-multiplication operator is:
operator *(num other) → numThis operator-multiplication operator of int multiplication operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | The other number to multiply with. |
✐ Examples
1 Multiplication
In this example,
- We create two integer variables
num1andnum2with values 5 and 3 respectively. - We use the
*operator to perform the multiplication operation betweennum1andnum2. - We then print the result to standard output.
Dart Program
void main() {
int num1 = 5;
int num2 = 3;
int result1 = num1 * num2;
print('Multiplication of $num1 and $num2: $result1');
}Output
Multiplication of 5 and 3: 15
2 Multiplication
In this example,
- We create two integer variables
num3andnum4with values 10 and -2 respectively. - We use the
*operator to perform the multiplication operation betweennum3andnum4. - We then print the result to standard output.
Dart Program
void main() {
int num3 = 10;
int num4 = -2;
int result2 = num3 * num4;
print('Multiplication of $num3 and $num4: $result2');
}Output
Multiplication of 10 and -2: -20
3 Multiplication
In this example,
- We create two integer variables
num5andnum6with values -4 and -3 respectively. - We use the
*operator to perform the multiplication operation betweennum5andnum6. - We then print the result to standard output.
Dart Program
void main() {
int num5 = -4;
int num6 = -3;
int result3 = num5 * num6;
print('Multiplication of $num5 and $num6: $result3');
}Output
Multiplication of -4 and -3: 12
Summary
In this Dart tutorial, we learned about operator-multiplication operator of int: the syntax and few working examples with output and detailed explanation for each example.