Skip to content

Instantly share code, notes, and snippets.

@amani27
Last active December 20, 2022 08:54
Show Gist options
  • Select an option

  • Save amani27/8d9c74af7dc09d882236f390e7cf1dc3 to your computer and use it in GitHub Desktop.

Select an option

Save amani27/8d9c74af7dc09d882236f390e7cf1dc3 to your computer and use it in GitHub Desktop.
Demonstrating Dart arithmetic operators
void main() {
int a = 16;
int b = 5;
var c = a / b; // Division operator
print('c = $c'); // Returns division result - double values
var i = a ~/ b; // Tilde slash operator
print('i = $i'); // Returns integer part of division result
var r = a % b; // Modulus operator
print('r = $r'); // Returns remainder of division
++a;
print('a = $a');
a++;
print('a = $a');
int a1, a2;
a1 = a++; // first assigns value and only then increments
print('a1 = $a1');
a2 = ++a; // vice-versa to a++
// first increments and then assigns value
print('a2 = $a2');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment