Skip to main content

//Arthmatic Operator

Arthmatic Operator


CODE

👇

  1. class arop //class Declaration; class name same as file name. when save in local file
  2. {
  3. public static void main(String args[]) //Main Method
  4. {
  5. int  a = 21; // initializing variables
  6. int b = 10;
  7. int c;

  8. //Addition
  9. c = a + b;
  10. System.out.println("Line 1 - value of c is :"+c); // '+c' is used to indicate which value should be print.

  11. //Subtraction
  12. c = a - b;
  13. System.out.println("Line 2 - value of c is :"+c); //"System.out.println" use for print line.
  14. //Multiplication
  15. c = a * b;
  16. System.out.println("Line 3 - value of c is :"+c); 

  17. //Division
  18. c = a / b;
  19. System.out.println("Line 4 - value of c is :"+c);

  20. //Modulus
  21. c = a % b;
  22. System.out.println("Line 5 - value of c is :"+c);
  23. }
  24. }


👉Execute👈


//Output

/*

the value of c is :31

the value of c is :11

the value of c is :210

the value of c is :2.1

the value of c is :1 

*/




                                                                        //ThE ProFessoR