Arithmetic operator in java with example
There are many types of operators in java :
- Arithmetic operator
- Unary operator
- Relational operator
- Logical operator
- Assignment operator
- Ternary operator
- Bitwise operator
1. Arithmetic Operator :
Arithmetic operator is used to perform the mathematical operation by the help of arithmetic operator on the operands( variable ). Syntax : operand1 operator operand 2 ;
Arithmetic operator symbol.
- Addition : +
- Subtraction : -
- Multiplication : *
- Division: /
- Modulo: %
Addition : It gives the Summation of operand or variables.
example of addition operator.int a=5, b=2,c;
c =a+ b; // Output 7
Subtraction : This operation is performed to find the difference between the operand.
example of subtraction operator :
int sub , a=5 , b=2 ;
sub=a-b; // Output 3
Multiplication : This operator is used to find the product of operand .
example of subtraction operator :
int sub , a=5 , b=2 ;
sub=a-b; // Output 3
Multiplication : This operator is used to find the product of operand .
example of multiplication operator :
int mul , b=2,d=3;
mul=d*b ; //Output 6
int mul , b=2,d=3;
mul=d*b ; //Output 6
Division : It is used to find the quotient .
example of Division operator:
int div , b=2,e=6;
div=e/b; //Output 3
int div , b=2,e=6;
div=e/b; //Output 3
Modulo : This operator is used to find the remainder .
example of modulo operatorint mod , b=2,e=6;
mod=e% b; // Output 0
Write a program for use of Arithmetic operators.
In this program we use all the arithmetic operators .
OUTPUT:
Tags:
PROGRAMMING