Arithmetic operator in java

 Arithmetic operator in java with example

There are many types of operators in java :

  1. Arithmetic operator 
  2. Unary operator
  3. Relational operator
  4. Logical operator
  5. Assignment operator
  6. Ternary operator
  7. 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: %
Java Arithmetic Operators with example

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 multiplication operator :
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

Modulo : This operator is used to find the remainder .

example of modulo operator
int 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:





Post a Comment

have you any doubt then ask.

Previous Post Next Post