Arithmetic Operators

Source Code

package MyPackage;

public class ArithmeticOperators { 


public static void main(String[] args) {


int x , y , answer ;

// declare double for decimal values

x = 70;

y = 30;

answer = x / y;

/*

answer = x - y;   -- returns subtraction

answer = x * y;   -- returns multiplication

answer = x / y;   -- returns integer value

answer = x % y;   -- returns remainder

*/

System.out.println("Answer = " + answer);

}

}

 Output

Answer = 2


Post a Comment

0 Comments