JAVA programs

Program Using Arithmetic Operator

Arithmetic operator like +,  -, *, / ,% are used for addition, subtraction, multiplication, division, module division respectively.

In this program we learn use of arithmetic operator, using that we perform arithmetic operation.

It is simple program that take two inputs perform operation and save result in third variable

Program

class ArithmeticOperator

{

    public static void main(String[] args)

    {

        int x=20;

        int y=30;

        int z;

         z=x+y;

        System.out.println("The addition is:"+z);

        z=x-y;

        System.out.println("The substraction is:"+z);

        z=x*y;

        System.out.println("The multiplication is:"+z);

        z=x/y;

        System.out.println("The division is:"+z);

        z=x%y;

        System.out.println("The remainder is:"+z);

    }

}

When Run The Program Following Output:

See following window

Description

Using Arithmetic operator like +,  -, *, / ,% we perform operation like addition, subtraction, multiplication, division, module division.

 

In above program we perform Arithmetic operation on two variables and store the result in third variable. And then printed the value of third variable.

 

Releted Programs

© 2017 codewmAll rights reserved.