# Basic Arithmetic Operators in Java Programming.

Arithmetic Operators involves the mathematical operators used to perform basic math equation on the primitive data types referred to as the operands. By learning these basic operators, in the future you are able to make your own algorithm that requires many alternative solution. In this blog, I will show you a sample codes that applying the arithmetic operators.

Sample Operator and Their Result:

Now, Let’s look at each one of the arithmetic operators.

1. Addition(+) – It is a binary operator and used to add two operands.

Syntax:
n1+n2

Example:
n1 = 10 , n2 = 10
sum = n1+n2 = 20

Sample Code :

Output:

2. Subtraction(-) – It is a binary operator and used to subtract two operands.

Syntax:
n1-n2

Example:
n1 = 10 , n2 = 10
diff = n1-n2 = 0

Sample Code :

Output:

3. Multiplication(*) – It is a binary operator and used to multiply two operands.

Syntax:
n1*n2

Example:
n1 = 10 , n2 = 10
prod = n1*n2 = 100

Sample Code:

Output:

4. Division(/) – It is a binary operator and used to divide two operands.

Syntax:
n1/n2

Example:
n1 = 10 , n2 = 10
prod = n1/n2 = 1

Sample Code:

Output:

5. Modulo(%) – It is a binary operator and used to return the remainder when the first operand(dividend) is divided by the second operand(divisor).

Syntax:
n1%n2

Example:
n1 = 10 , n2 = 10
mod = n1%n2 = 0

Sample Code:

Output:

Conclusion

After learning this basic operators, you are able to make your own formula and also make your Java project as your personal calculator. Applying this operators is not just only for two numbers but also for multiple numbers. Hope this code will guide you in making a simple math calculator.