Java Program To Demonstrate Compound Operators

Java Program To Demonstrate Compound Operators

Write Java Program to demonstrate the use of compound operators

//WAP to demonstrate the use of compound operators

public class CompoundOperator
{
    public static void main(String[] args) 
    {
        int a = 7,c;
        System.out.println("The value of a is : "+a);
        
        c = a; // c is 5
        System.out.println("c = a ->c = "+c);

        c+= a; // c = a + c 
        System.out.println("c += a->c = "+c);

        c-= a; // c = c - a 
        System.out.println("c -= a->c = "+c);

        c*= a; // c = c * a 
        System.out.println("c *= a->c = "+c);

        c/= a; // c = c / a 
        System.out.println("c += a->c = "+c);

        c%= a; // c = c % a 
        System.out.println("c mode a->c = "+c);

    }
}

Output: