Tue Aug 24 2021

Arithmetic Operations

File Name: Arithmetic-operations.java

import java.io.*;

class calculation {
	public static void main(String args[ ]) {
		int sum, sub, mul, div, mod;
		System.out.println("Calculation in Java");

		/* Calculation of Sum */
		sum = 1 + 2;

		/* Calculation of Subtract */
		sub = 3 - 2;

		/* Calculation of Multiplication */
		mul = 2 * 2;

		/* Calculation of Division */
		div = 4 / 2;

		/* Calculation of Modulus */
		mod = 3 % 2;
		System.out.println("Sum: "+sum);
		System.out.println("Subtract: "+sub);
		System.out.println("Multiplication: "+mul);
		System.out.println("Division: "+div);
		System.out.println("Modulus: "+mod);
	}
}



/* Output */
Calculation in Java
Sum: 3
Subtract: 1
Multiplication: 4
Division: 2
Modulus: 1

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.