Basic Arithmetic Operations in Java


Understanding basic arithmetic operations is crucial for performing calculations.

Source Code

public class ArithmeticOperations {
    public static void main(String[] args) {
        int a = 10, b = 5;
        System.out.println("a + b = " + (a + b));
        System.out.println("a - b = " + (a - b));
        System.out.println("a * b = " + (a * b));
        System.out.println("a / b = " + (a / b));
        System.out.println("a % b = " + (a % b)); // Modulus (remainder)
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments