Arthmatic Operator
CODE
👇
- class arop //class Declaration; class name same as file name. when save in local file
- {
- public static void main(String args[]) //Main Method
- {
- int a = 21; // initializing variables
- int b = 10;
- int c;
- //Addition
- c = a + b;
- System.out.println("Line 1 - value of c is :"+c); // '+c' is used to indicate which value should be print.
- //Subtraction
- c = a - b;
- System.out.println("Line 2 - value of c is :"+c); //"System.out.println" use for print line.
- //Multiplication
- c = a * b;
- System.out.println("Line 3 - value of c is :"+c);
- //Division
- c = a / b;
- System.out.println("Line 4 - value of c is :"+c);
- //Modulus
- c = a % b;
- System.out.println("Line 5 - value of c is :"+c);
- }
- }
👉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