You are here: Home / Topics / Decrement Operator example in Java

Decrement Operator example in Java

Filed under: Java on 2023-08-11 19:25:39

// Decrement Operator Example

class DecrementOperatorExample
{
public static void main( String args[ ] )
{
 int a = 10, b = 20 ,c;
 
 c = ( --a ) + ( --b );

 //c = ( a-- ) + ( b-- );
 
 System.out.println( " Value of a = " + a );
 System.out.println( " Value of b = " + b );
 System.out.println( " Value of c = " + c );
}
}


Output:

Value of a = 9
Value of b = 19
Value of c = 28

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