SOURCE CODE
class IncDec { // start class IncDec.
public static void main(String args[]) { // start of main() method.
int a=10, b=15; // initializing variables.
System.out.println("Original Numbers are a="+a+ " b="+b); // Printing the original Numbers
a++; // incrementing variable a.
b--; // decrementing variable b.
System.out.println("After Increment a="+a+ " After Decrements b="+b); // printing the results.
} //end of main() method.
} // end of class IncDec.
OUTPUT
Original Numbers are a=10 b=15
After Increment a=11 After Decrements b=14
NOTE:-
Above program increment the variable a by 1 and decrements the variable by 1. And then it prints the result.
If you want to increase or decrease the value of variable by more than 1 then you have to usec = b+2 or c = b+any_Number.
0 comments:
Post a Comment