Arithmetic Operator in JAVA
There are different types of operators in java programming language. one of them is arithmetic operator. Arithmetic operators are used to do arithmetic operations in java. The sign used on arithmetic operation are listed below.
1) Addition +
2) Subtraction -
3) Division /
4) Multiplication *
5) Modulo % ( It gives reminder after division)
Example below displays the source code of performing arithmetic operation.
package operators;
public class ArithmeticOperators {
// basically there are 5 types of arithmetic operator
// 1) addition +
// 2) Subtraction -
// 3) multiplication *
// 4) division /
// 5) modulo %
public static void main(String[] args) {
int a = 10;
int b = 22;
// lets do addition first
System.out.println("Total sum = " + (a + b));
// subtraction
System.out.println("b - a = " + (b - a));
// multiplication
System.out.println("a * b = " + (a * b));
// division
System.out.println("a / a = " + (b / a));
// modulo > it displays remainder
System.out.println("a % b = " + (b % a));
}
}
Comments
Post a Comment