Write a program which shows the function of increment(++).

Category : Java | Sub Category : Operator | By Runner Dev Last updated: 2020-09-28 18:57:22 Viewed : 196


(Operator)

Write a program which shows the function of increment(++).

 


Source Code: 


/**

 * Write a program which shows the function of increment(++).

 *

 */

 

class InDec { // Class name and class start from here.

     public static void main(String a[]) { // main method of program line.

           int a = 1; // Initialize1 in variable a.

           int b = 2; // Initialize 2 in variable b.

           int c, d; // daclare two variables c & d.

           c = ++b; // increment in b than store in c.

           d = a++; // store value of a in d. than increment in i.

           System.out.println("a = " + a); // this print the value a. //a=2

           System.out.println("b = " + b); // this print the value b.// b=3

           System.out.println("c = " + c); // this print the value c. //c=4

           System.out.println("d = " + d); // this print the value d. //d=1

     }

}

 OUTPUT:


Search
Related Articles

Leave a Comment: