Increment & Decrement Operator - Devbhoomi

FREE JOB ALERT & ONLINE TUTORIALS

Hot

Post Top Ad

Sunday 5 November 2017

Increment & Decrement Operator

  • Increment operator (++) increases the value of its operand by 1
  • Decrement operator (--) decreases the value of its operand by 1
Example :

    int x;
    int y;

    // Increment operators
    x = 1;

    y = ++x; // x is now 2, y is also 2
    y = x++; // x is now 3, y is 2

    // Decrement operators
    x = 3;
    y = x--; // x is now 2, y is 3
    y = --x; // x is now 1, y is also 1

No comments:

Post a Comment

Post Top Ad