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 241 views
241 views asked Oct 12, 2022 by avibootz
1 answer 276 views
1 answer 249 views
249 views asked Dec 19, 2022 by avibootz
2 answers 285 views
285 views asked Nov 3, 2022 by avibootz
2 answers 315 views
1 answer 224 views
224 views asked Nov 3, 2022 by avibootz
2 answers 299 views
299 views asked Oct 22, 2022 by avibootz
...