You are here: Home / Topics / Program to use Short-Hand Assignment Operators in Java

Program to use Short-Hand Assignment Operators in Java

Filed under: Java on 2023-08-11 19:32:24

//  Program to use Short-Hand Assignment Operators ( +=, -=, *=, /=, %= )

class ShortHandAssign 
{
public static void main(String args[ ]) 
{
 int a = 1;
 int b = 2;
 int c = 3;
 a += 5;
 b *= 4;
 c += a * b;
 c %= 6;
 System.out.println("a = " + a);
 System.out.println("b = " + b);
 System.out.println("c = " + c);
}
}


Output:

a = 6
b = 8
c = 3

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.