Assignment Operators Example Program in Dart


The code is written in the Dart programming language and demonstrates the use of some basic arithmetic operations and assignment operators. Here is what the code does:

  • Declare a variable named a and initialize it to the value 40.
  • Print the value of a.
  • Add 10 to the value of a and print the new value.
  • Subtract 10 from the value of a and print the new value.
  • Multiply the value of a by 2 and print the new value.
  • Declare a variable named c and initialize it to the value 80.
  • Divide the value of c by 8 and print the result.
  • Set the value of a to 123.
  • Take the remainder of a divided by 10 and print the result.

Source Code

void main() {
   var a=40;
   print('A value : ${a}');
   a+=10; //a=a+10
   print('A value : ${a}');
   a-=10;
   print('A value : ${a}');
   a*=2;
   print('A value : ${a}');
   double c=80;
   c/=8;
   print('A value : ${c}');
   a=123;
   a%=10;//a=a%10
   print('A value : ${a}');
}
To download raw file Click Here

Output

A value : 40
A value : 50
A value : 40
A value : 80
A value : 10.0
A value : 3