Skip to main content

//Assignment Operators

 //Assignment Operators


CODE

👇

  1. class assop //class Declaration; class name same as file name. when you save in local file
  2. {
  3. public static void main(String args[])
  4. {
  5. int a = 21; // initializing variables
  6. int c = 10;
  7. //Add AND
  8. c += a; //c = c + a; 10 + 21 = 31;
  9. System.out.println("the addition is:"+c); // '+c' is used to indicate which value should be print.

  10. //Multiply AND
  11. c *= a; //c = c * a; 10 * 21 = 210;
  12.         System.out.println("the multiplication is:"+c); //"System.out.println" use for print line.

  13.     //Subtract AND
  14. c -= a; //c = c - a; 31 - 21 = 10;
  15.         System.out.println("the substraction is:"+c);

  16. //Divison AND
  17. c /= a; // c = c /a; 210/10 = 10;
  18.         System.out.println("the division is:"+c);

  19.     //Mod AND
  20. c %= a; // c = c % a; 10 % 10 =10;
  21.         System.out.println("the modulos is:"+c);


  22. }
  23. }


👉Execute👈


//Output

/*

   the value of c is :31

   the value of c is :10

   the value of c is :210

   the value of c is :10

   the value of c is :10 

 */



//ThE ProFessoR