How to use arithmetic operators in Dart

1 Answer

0 votes
void main() {
    var x = 10;
    var y = 4;
 
    var addition = x + y;
    var subtraction = x - y;
    var multiplication = x * y;
    var division = x / y;
    var division_integer = x ~/ y;
    var modulus = x % y;
    var increment = ++x;
    var decrement = --y;
 
    print('x + y = $addition');
    print('x - y = $subtraction');
    print('x * y = $multiplication');
    print('x / y = $division');
    print('x ~/ y = $division_integer');
    print('x % y = $modulus');
    print('++x = $increment');
    print('--y = $decrement');
}
   

   
   
/*
run:

x + y = 14
x - y = 6
x * y = 40
x / y = 2.5
x ~/ y = 2
x % y = 2
++x = 11
--y = 3
   
*/

 



answered Oct 11, 2022 by avibootz

Related questions

1 answer 238 views
238 views asked Oct 12, 2022 by avibootz
1 answer 274 views
1 answer 247 views
247 views asked Dec 19, 2022 by avibootz
2 answers 279 views
279 views asked Nov 3, 2022 by avibootz
2 answers 310 views
1 answer 218 views
218 views asked Nov 3, 2022 by avibootz
2 answers 295 views
295 views asked Oct 22, 2022 by avibootz
...