Dart

Dart Arithmetic Operators

Dart Arithmetic Operators

Arithmetic Operators are used to perform arithmetic operations on operands. Most of the Dart arithmetic operators are binary, meaning they operate on two operands.

Dart operators:

https://www.testingdocs.com/dart-operators/

The following table describes the symbols, names, and descriptions of the Dart arithmetic operators:

 

Operator Symbol Operation Name  Description
  + Addition Adds two operands
 – Subtraction Subtracts two operands
 * Multiplication Multiplies two operands
  / Division Divides two operands
 % Modulus Returns the remainder of the division of two operands
-/ Integer Division Divides two operands and returns the result as an integer
  –expr Unary Minus Reverses the sign of the expression

 

Demo Program

/*
* Arithmetic Operators Dart Program
* Dart Tutorials - www.TestingDocs.com
*/
void main()
{
// Declare two variables
int a=7;
int b=9;

//Add a and b
var sum= a+b;
print ("The sum of a and b is = $sum");

// Subtract a and b
var diff= a-b;
print("The difference between a and b is = $diff");

//Multiplication of a and b
var product= a*b;
print("The product of a and b is = $product");

// Division of a and b
var quot=b/a;
print("The quotient of a and b is = $quot");

//Remainder of a and b
var rem=b%a;
print("The remainder of a and b is = $rem");
}

Dart Arithmetic Operators IDE

Program Output

C:/tools/dart-sdk/bin/dart.exe –enable-asserts C:\Users\testingdocs\SampleDartProject\arithmetic.dart
The sum of a and b is = 16
The difference between a and b is = -2
The product of a and b is = 63
The quotient of a and b is = 1.2857142857142858
The remainder of a and b is = 2

 

Dart Arithmetic Operators Program Output