Posted by : Unknown
Sunday, 28 June 2015
class arithmetic
{
public static void main(String args[])
{
short x = 8;
int y = 2;
float a = 10.5f;
float b = 6f;
System.out.println("Addition: "+(x+y));
System.out.println("Subtraction: "+(x-y));
System.out.println("Multiplication: "+(x*y));
System.out.println("Division: "+(x/y));
System.out.println("Modulus: "+(x%y));
System.out.println("Floating point Division: "+(a/b));
}
}
{
public static void main(String args[])
{
short x = 8;
int y = 2;
float a = 10.5f;
float b = 6f;
System.out.println("Addition: "+(x+y));
System.out.println("Subtraction: "+(x-y));
System.out.println("Multiplication: "+(x*y));
System.out.println("Division: "+(x/y));
System.out.println("Modulus: "+(x%y));
System.out.println("Floating point Division: "+(a/b));
}
}
Output:
Addition: 10
Subtraction: 6
Multiplication: 16
Division: 4
Modulus: 0
Floating point Division: 1.75
Subtraction: 6
Multiplication: 16
Division: 4
Modulus: 0
Floating point Division: 1.75
Related Posts :
- Back to Home »
- Example program , Simple Program »
- Simple Arithmetic Operators