Sunday, June 2, 2013

Nine Increment and Decrement Operator

import java.util.Scanner;



class NineIncrementdOperator {

    public static void main(String[] args) {
       
        Scanner bucky = new Scanner(System.in);
       
        int Increment =5;
       
        int Decrement =5;
       
        Increment ++;
        System.out.println( Increment);// here value of Increment is 5+1 = 6
       
        ++Increment;
        System.out.println(Increment); // here value of Increment is 7
       
       
        Decrement --;
        System.out.println(Decrement);// here value of Increment is 4
       
        --Decrement;
        System.out.println(Decrement); // here value of Increment is 3
       
        Increment += 8; // adding 8 to variable
        System.out.println(Increment); // here value of Increment is
               
        Increment *= 8; // Multiply 8 to variable
        System.out.println(Increment); // here value of Increment is 120
       
        Increment /= 8; // divide 8 to variable
        System.out.println(Increment); // here value of Increment is 120 / 8 = 15
       
        Increment %= 8; // remainder 8 to variable
        System.out.println(Increment); // here value of Increment is 15 % 8 = 7
    }

}

===============Out put ===========================
6
7
4
3
15
120
15
7

No comments:

Post a Comment